Add Pseudo Move Generator #12
@@ -106,4 +106,12 @@ void create_knight_attack_cache();
|
|||||||
void create_pawn_attack_cache();
|
void create_pawn_attack_cache();
|
||||||
void create_king_attack_cache();
|
void create_king_attack_cache();
|
||||||
void print_board();
|
void print_board();
|
||||||
int gen_pseudo_moves(struct Board *b, struct Move *out, bool captures_only);
|
void gen_white_pawn_quiet_pushes(const struct Board *board, struct Move *moves, int *count);
|
||||||
|
void gen_black_pawn_quiet_pushes(const struct Board *board, struct Move *moves, int *count);
|
||||||
|
void gen_white_pawn_push_promotions(const struct Board *board, struct Move *moves, int *count);
|
||||||
|
void gen_black_pawn_push_promotions(const struct Board *board, struct Move *moves, int *count);
|
||||||
|
void gen_white_pawn_captures(const struct Board *board, struct Move *moves, int *count);
|
||||||
|
void gen_black_pawn_captures(const struct Board *board, struct Move *moves, int *count);
|
||||||
|
void gen_white_pawn_capture_promotions(const struct Board *board, struct Move *moves, int *count);
|
||||||
|
void gen_black_pawn_capture_promotions(const struct Board *board, struct Move *moves, int *count);
|
||||||
|
int gen_pseudo_moves(const struct Board *board, struct Move *out, bool captures_only);
|
||||||
@@ -458,7 +458,7 @@ void gen_queen_moves(const struct Board *board, struct Move *out, int *count, bo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gen_king_moves(struct Board *board, struct Move *out, int *count, bool captures_only) {
|
void gen_king_moves(const struct Board *board, struct Move *out, int *count, bool captures_only) {
|
||||||
enum Color side = board->side_to_move;
|
enum Color side = board->side_to_move;
|
||||||
uint64_t own = board->occ[side];
|
uint64_t own = board->occ[side];
|
||||||
uint64_t opp = board->occ[side ^ 1];
|
uint64_t opp = board->occ[side ^ 1];
|
||||||
@@ -502,6 +502,35 @@ void gen_king_moves(struct Board *board, struct Move *out, int *count, bool capt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int gen_pseudo_moves(const struct Board *board, struct Move *moves, bool captures_only) {
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
if (board->side_to_move == WHITE) {
|
||||||
|
if (!captures_only) {
|
||||||
|
gen_white_pawn_quiet_pushes(board, moves, &count);
|
||||||
|
gen_white_pawn_push_promotions(board, moves, &count);
|
||||||
|
}
|
||||||
|
gen_white_pawn_captures(board, moves, &count);
|
||||||
|
gen_white_pawn_capture_promotions(board, moves, &count);
|
||||||
|
} else {
|
||||||
|
if (!captures_only) {
|
||||||
|
gen_black_pawn_quiet_pushes(board, moves, &count);
|
||||||
|
gen_black_pawn_push_promotions(board, moves, &count);
|
||||||
|
}
|
||||||
|
gen_black_pawn_captures(board, moves, &count);
|
||||||
|
gen_black_pawn_capture_promotions(board, moves, &count);
|
||||||
|
}
|
||||||
|
|
||||||
|
gen_knight_moves(board, moves, &count, captures_only);
|
||||||
|
gen_king_moves(board, moves, &count, captures_only);
|
||||||
|
gen_rook_moves(board, moves, &count, captures_only);
|
||||||
|
gen_bishop_moves(board, moves, &count, captures_only);
|
||||||
|
gen_queen_moves(board, moves, &count, captures_only);
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void print_board(const struct Board *board) {
|
void print_board(const struct Board *board) {
|
||||||
const char PIECE_CH[12] = {
|
const char PIECE_CH[12] = {
|
||||||
'P','N','B','R','Q','K',
|
'P','N','B','R','Q','K',
|
||||||
|
|||||||
Reference in New Issue
Block a user