prob. finished the pseudocode in main.c

This commit is contained in:
Odweta
2026-02-17 16:35:32 +01:00
parent d94e04f8ef
commit 69390eb187
2 changed files with 50 additions and 1 deletions
+32 -1
View File
@@ -18,9 +18,35 @@
#define BOARD_HORIZONTAL 8 #define BOARD_HORIZONTAL 8
#define BOARD_VERTICAL 8 #define BOARD_VERTICAL 8
// just a simple type abstraction // type abstractions
typedef int board_t[BOARD_HORIZONTAL][BOARD_VERTICAL]; typedef int board_t[BOARD_HORIZONTAL][BOARD_VERTICAL];
typedef enum {
NONE,
PAWN,
ROOK,
KNIGHT,
BISHOP,
QUEEN,
KING
} piece_e;
typedef struct {
int x;
int y;
} pos_t;
typedef enum { WHITE, BLACK } player_e;
typedef struct {
// what
// where from
// where to
piece_e piece;
pos_t from;
pos_t to;
} move_t;
// the default arrangment of pieces on the board // the default arrangment of pieces on the board
#define BOARD_DEFAULT_CONFIG \ #define BOARD_DEFAULT_CONFIG \
{\ {\
@@ -33,6 +59,11 @@ typedef int board_t[BOARD_HORIZONTAL][BOARD_VERTICAL];
{2,3,4,5,6,4,3,2}\ {2,3,4,5,6,4,3,2}\
} }
typedef enum {
CHECKMATE,
STALEMATE
} end_condition_e;
// initializes the board with the default configuration of pieces // initializes the board with the default configuration of pieces
bool init_board(board_t *board); bool init_board(board_t *board);
+18
View File
@@ -16,14 +16,32 @@
*/ */
int main() { int main() {
// variable defs
board_t board; board_t board;
move_t move;
player_e player;
end_condition_e end_condition;
bool running = true; bool running = true;
// algo begin
init_board(&board); init_board(&board);
while (running) { while (running) {
select_player(&player);
get_move(&move);
perform_move(player, move);
end_condition = check_edge_cases(board);
if (end_condition == CHECKMATE || end_condition == STALEMATE) {
running = false;
}
} }
announce_results(player);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }