diff options
| author | Aargh Rai <aargh.rai+git@gmail.com> | 2026-06-02 17:39:09 +0530 |
|---|---|---|
| committer | Aargh Rai <aargh.rai+git@gmail.com> | 2026-06-02 17:39:09 +0530 |
| commit | 058f12c699c9183f93f280ad7eb54c8a1b25f523 (patch) | |
| tree | f06f21c94666243b80a5823c3932349dba4ed3cc /src/engine/moves/rook.c | |
| parent | df577a30f2df1d60a0254403147fd2077a7c8b42 (diff) | |
added move flags
will try stockfish later dw
Diffstat (limited to 'src/engine/moves/rook.c')
| -rw-r--r-- | src/engine/moves/rook.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/engine/moves/rook.c b/src/engine/moves/rook.c index c5867d5..dfd9c32 100644 --- a/src/engine/moves/rook.c +++ b/src/engine/moves/rook.c @@ -15,9 +15,11 @@ void __forloop_rook_moves_gen( int rank = og_rank + 1, file = og_file, index = rank * 8 + file; + bitboard_t occupied; while (rank < 8 && !occupied_by(friendly_pieces, index)) { - add_move(moves, from, index); - if (occupied_by(enemy_pieces, index)) { + occupied = occupied_by(enemy_pieces, index); + add_move(moves, from, index, .flags = occupied ? MOVE_CAPTURE : 0); + if (occupied) { break; } index = ++rank * 8 + file; @@ -25,8 +27,9 @@ void __forloop_rook_moves_gen( 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)) { + occupied = occupied_by(enemy_pieces, index); + add_move(moves, from, index, .flags = occupied ? MOVE_CAPTURE : 0); + if (occupied) { break; } index = --rank * 8 + file; @@ -34,8 +37,9 @@ void __forloop_rook_moves_gen( 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)) { + occupied = occupied_by(enemy_pieces, index); + add_move(moves, from, index, .flags = occupied ? MOVE_CAPTURE : 0); + if (occupied) { break; } index = rank * 8 + ++file; @@ -43,8 +47,9 @@ void __forloop_rook_moves_gen( 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)) { + occupied = occupied_by(enemy_pieces, index); + add_move(moves, from, index, .flags = occupied ? MOVE_CAPTURE : 0); + if (occupied) { break; } index = rank * 8 + --file; |
