started work on the movement logic
This commit is contained in:
+1
-1
@@ -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
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user