diff options
Diffstat (limited to 'src/engine/moves.h')
| -rw-r--r-- | src/engine/moves.h | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/engine/moves.h b/src/engine/moves.h index b63b9e2..bd88eeb 100644 --- a/src/engine/moves.h +++ b/src/engine/moves.h @@ -6,9 +6,27 @@ typedef u8 square_t; +// think about the chess move notation +// e4, Nf6, Qh3+, Qe1#, a8=Q, i need to store the information needed to +// recreate this in move_t +enum { + MOVE_CAPTURE = 1, + MOVE_SHORT_CASTLE = 1 << 1, + MOVE_LONG_CASTLE = 1 << 2, + + // technically these promotation flags can be compressed to only use 2 bits.. + MOVE_PROMOTE_Q = 1 << 3, // 1 << 5 + MOVE_PROMOTE_R = 1 << 4, // 2 << 5 + MOVE_PROMOTE_B = 1 << 5, // 3 << 5 + MOVE_PROMOTE_N = 1 << 6, // 4 << 5 ? nvm it uses 3 + MOVE_EN_PASSANT = 1 << 7, + MOVE_CHECK = 1 << 8, +}; + typedef struct { square_t from; square_t to; + u16 flags; } move_t; void position_make_move(position_t* position, move_t* move); @@ -21,7 +39,22 @@ typedef struct { moves_t moves_init(); moves_t moves_init_wcapacity(u32 capacity); moves_t moves_empty(); -void add_move(moves_t* moves, square_t from, square_t to); + +struct add_move_params { + u16 flags; +}; +#define add_move(moves, from, to, ...) _add_move(\ + moves, \ + from, \ + to, \ + (struct add_move_params) { .flags = 0, __VA_ARGS__ }\ +) +void _add_move( + moves_t* moves, + square_t from, + square_t to, + struct add_move_params params +); void get_pawn_moves(moves_t* moves, position_t position); void get_knight_moves(moves_t* moves, position_t position); |
