diff --git a/src/chess.h b/src/chess.h index b5a028d..046ec17 100644 --- a/src/chess.h +++ b/src/chess.h @@ -18,9 +18,35 @@ #define BOARD_HORIZONTAL 8 #define BOARD_VERTICAL 8 -// just a simple type abstraction +// type abstractions 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 #define BOARD_DEFAULT_CONFIG \ {\ @@ -33,6 +59,11 @@ typedef int board_t[BOARD_HORIZONTAL][BOARD_VERTICAL]; {2,3,4,5,6,4,3,2}\ } +typedef enum { + CHECKMATE, + STALEMATE +} end_condition_e; + // initializes the board with the default configuration of pieces bool init_board(board_t *board); diff --git a/src/main.c b/src/main.c index c6424b5..cccb8e4 100644 --- a/src/main.c +++ b/src/main.c @@ -16,14 +16,32 @@ */ int main() { + // variable defs board_t board; + move_t move; + player_e player; + end_condition_e end_condition; bool running = true; + // algo begin + init_board(&board); 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; } \ No newline at end of file