diff options
| author | Aargh Rai <aargh.rai+git@gmail.com> | 2026-05-27 18:02:44 +0530 |
|---|---|---|
| committer | Aargh Rai <aargh.rai+git@gmail.com> | 2026-05-27 18:02:44 +0530 |
| commit | 2c2a70b69869f149c0407a62f1bf4c39899027a7 (patch) | |
| tree | 9c3d194c32e82039fe6e0da9fbaf2e86aeef0a59 /src/search/rook_moves.c | |
| parent | 58b2c8b6e2041e63c46b579eccc141d21801e985 (diff) | |
restructing
Diffstat (limited to 'src/search/rook_moves.c')
| -rw-r--r-- | src/search/rook_moves.c | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/src/search/rook_moves.c b/src/search/rook_moves.c deleted file mode 100644 index 3e25526..0000000 --- a/src/search/rook_moves.c +++ /dev/null @@ -1,77 +0,0 @@ -#include "search.h" - -void __forloop_rook_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] - int rank = og_rank + 1, file = og_file, index = rank * 8 + file; - - - while (rank < 8 && !occupied_by(friendly_pieces, index)) { - add_move(moves, from, index); - if (occupied_by(enemy_pieces, index)) { - break; - } - index = ++rank * 8 + file; - } - - rank = og_rank - 1, file = og_file, index = rank * 8 + file; - while (rank >= 0 && !occupied_by(friendly_pieces, index)) { - add_move(moves, from, index); - if (occupied_by(enemy_pieces, index)) { - break; - } - index = --rank * 8 + file; - } - - rank = og_rank, file = og_file + 1, index = rank * 8 + file; - while (file < 8 && !occupied_by(friendly_pieces, index)) { - add_move(moves, from, index); - if (occupied_by(enemy_pieces, index)) { - break; - } - index = rank * 8 + ++file; - } - - rank = og_rank, file = og_file - 1, index = rank * 8 + file; - while (file >= 0 && !occupied_by(friendly_pieces, index)) { - add_move(moves, from, index); - if (occupied_by(enemy_pieces, index)) { - break; - } - index = rank * 8 + --file; - } - } -} - -void get_rook_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]; - } - - __forloop_rook_moves_gen( - moves, - friendly_rooks, - friendly_pieces, - enemy_pieces - ); -} |
