summaryrefslogtreecommitdiff
path: root/src/engine/moves/bishop.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/moves/bishop.c')
-rw-r--r--src/engine/moves/bishop.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/engine/moves/bishop.c b/src/engine/moves/bishop.c
index 52b90b3..c51d405 100644
--- a/src/engine/moves/bishop.c
+++ b/src/engine/moves/bishop.c
@@ -14,10 +14,11 @@ void __forloop_bishop_moves_gen(
int og_file = from % 8; // range: [0, 7]
int rank = og_rank + 1, file = og_file + 1, index = rank * 8 + file;
-
+ bitboard_t occupied;
while ((rank < 8 && 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;
@@ -25,8 +26,9 @@ void __forloop_bishop_moves_gen(
rank = og_rank - 1, file = og_file - 1, index = rank * 8 + file;
while ((rank >= 0 && 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;
@@ -34,8 +36,9 @@ void __forloop_bishop_moves_gen(
rank = og_rank - 1, file = og_file + 1, index = rank * 8 + file;
while ((rank >= 0 && 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 +46,9 @@ void __forloop_bishop_moves_gen(
rank = og_rank + 1, file = og_file - 1, index = rank * 8 + file;
while ((rank < 8 && 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;