summaryrefslogtreecommitdiff
path: root/src/engine/moves/rook.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/moves/rook.c')
-rw-r--r--src/engine/moves/rook.c21
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;