started work on the movement logic

This commit is contained in:
Odweta
2026-02-17 17:27:14 +01:00
parent 0816eaae24
commit 8ce26266f3
2 changed files with 26 additions and 1 deletions
+1 -1
View File
@@ -72,7 +72,7 @@ bool get_move(move_t *move) {
} }
bool perform_move(player_e player, move_t move) { bool perform_move(player_e player, move_t move) {
} }
end_condition_e check_edge_cases(board_t board) { end_condition_e check_edge_cases(board_t board) {
+25
View File
@@ -21,6 +21,8 @@
// type abstractions // type abstractions
typedef int board_t[BOARD_HORIZONTAL][BOARD_VERTICAL]; typedef int board_t[BOARD_HORIZONTAL][BOARD_VERTICAL];
#define PIECE_COUNT 7 // how many unique pieces are there
#define MAX_PIECE_MOVE_COUNT 27 // the max possible num of options where to move in one moment
typedef enum { typedef enum {
NONE, NONE,
PAWN, PAWN,
@@ -47,6 +49,11 @@ typedef struct {
pos_t to; pos_t to;
} move_t; } move_t;
typedef struct {
int dirx;
int diry;
} relative_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 \
(board_t){\ (board_t){\
@@ -59,6 +66,24 @@ typedef struct {
{2,3,4,5,6,4,3,2}\ {2,3,4,5,6,4,3,2}\
} }
typedef struct {
piece_e piece;
unsigned int piece_move_count;
relative_move_t moves[MAX_PIECE_MOVE_COUNT];
} valid_move_t;
/** FIXME: ALSO DEPENDS ON THE STATE OF THE GAME - e.g. a pawn cannot move two places in the middle of the game but can in the first round */
#define DEFAULT_VALID_MOVES \
(valid_move_t[PIECE_COUNT]){\
.piece = NONE, .count = 0, .moves = {}\
.piece = PAWN, .count = 0, .moves = {}\
.piece = ROOK, .count = 0, .moves = {}\
.piece = KNIGHT, .count = 0, .moves = {}\
.piece = BISHOP, .count = 0, .moves = {}\
.piece = QUEEN, .count = 0, .moves = {}\
.piece = KING, .count = 0, .moves = {}\
}
typedef enum { typedef enum {
CHECKMATE, CHECKMATE,
STALEMATE STALEMATE