started work on the movement logic
This commit is contained in:
+25
@@ -21,6 +21,8 @@
|
||||
// type abstractions
|
||||
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 {
|
||||
NONE,
|
||||
PAWN,
|
||||
@@ -47,6 +49,11 @@ typedef struct {
|
||||
pos_t to;
|
||||
} move_t;
|
||||
|
||||
typedef struct {
|
||||
int dirx;
|
||||
int diry;
|
||||
} relative_move_t;
|
||||
|
||||
// the default arrangment of pieces on the board
|
||||
#define BOARD_DEFAULT_CONFIG \
|
||||
(board_t){\
|
||||
@@ -59,6 +66,24 @@ typedef struct {
|
||||
{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 {
|
||||
CHECKMATE,
|
||||
STALEMATE
|
||||
|
||||
Reference in New Issue
Block a user