Files
chessc/src/main.c
T
2026-02-18 10:13:57 +01:00

51 lines
1.2 KiB
C

// a chess implementation in pure C :)
#include "util.h"
#include "chess.h"
/**
* steps to victory:
* 1. init the board with the default config
* 2. game loop
* 2a. select the current player (if first round - white starts)
* 2b. wait for the movement of the current player
* 2c. once a move is registered, perform it IF POSSIBLE
* 2d. check for captures and/or promotions and/or mates (check, stale...)
* 2e. if there is an end condition that is met, end the game; announce
* the results
*/
int main() {
// variable defs
board_t board;
move_t move;
player_e player;
unsigned int round_count = 0;
end_condition_e end_condition;
bool running = true;
// algo begin
init_board(&board);
show_help();
while (running) {
round_count++;
select_player(&player, round_count);
get_move(&move);
perform_move(&board, player, move);
end_condition = check_edge_cases(board);
if (end_condition == CHECKMATE || end_condition == STALEMATE) {
running = false;
}
}
announce_results(end_condition, player);
return EXIT_SUCCESS;
}