diff options
| author | Aargh Rai <aargh.rai+git@gmail.com> | 2026-05-26 14:22:55 +0530 |
|---|---|---|
| committer | Aargh Rai <aargh.rai+git@gmail.com> | 2026-05-26 14:22:55 +0530 |
| commit | ad32fc54b2869c0bbedcabea6274b0e3732ec893 (patch) | |
| tree | e4229b03c3f5ee4beea73db3d6614136ff3165e7 /src/search/bishop_moves.c | |
| parent | 7e021a821b49306eaa8b0688e4b91d2db25d4878 (diff) | |
bishop & queen
Diffstat (limited to 'src/search/bishop_moves.c')
| -rw-r--r-- | src/search/bishop_moves.c | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/src/search/bishop_moves.c b/src/search/bishop_moves.c index 10b46e5..29fe3a6 100644 --- a/src/search/bishop_moves.c +++ b/src/search/bishop_moves.c @@ -1,24 +1,14 @@ #include "search.h" -void get_bishop_moves(moves_t* moves, position_t position) { - assert_valid_position(position); - - bitboard_t friendly_rooks; - bitboard_t friendly_pieces; - bitboard_t enemy_pieces; - if (position.turn == WHITE_TURN) { - friendly_pieces = whites(position); - enemy_pieces = blacks(position); - friendly_rooks = position.bitboards[WHITE_ROOK]; - } else { - friendly_pieces = blacks(position); - enemy_pieces = whites(position); - friendly_rooks = position.bitboards[BLACK_ROOK]; - } - - while (friendly_rooks) { - int from = __builtin_ctzll(friendly_rooks); - friendly_rooks &= friendly_rooks - 1; +void __forloop_bishop_moves_gen( + moves_t* moves, + bitboard_t friendly_type, + bitboard_t friendly_pieces, + bitboard_t enemy_pieces +) { + while (friendly_type) { + int from = __builtin_ctzll(friendly_type); + friendly_type &= friendly_type - 1; int og_rank = from / 8; // range: [0, 7] int og_file = from % 8; // range: [0, 7] @@ -61,3 +51,22 @@ void get_bishop_moves(moves_t* moves, position_t position) { } } } + +void get_bishop_moves(moves_t* moves, position_t position) { + assert_valid_position(position); + + bitboard_t friendly_bishops; + bitboard_t friendly_pieces; + bitboard_t enemy_pieces; + if (position.turn == WHITE_TURN) { + friendly_pieces = whites(position); + enemy_pieces = blacks(position); + friendly_bishops = position.bitboards[WHITE_BISHOP]; + } else { + friendly_pieces = blacks(position); + enemy_pieces = whites(position); + friendly_bishops = position.bitboards[BLACK_BISHOP]; + } + + __forloop_bishop_moves_gen(moves, friendly_bishops, friendly_pieces, enemy_pieces); +} |
