summaryrefslogtreecommitdiff
path: root/src/search/bishop_moves.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/search/bishop_moves.c')
-rw-r--r--src/search/bishop_moves.c47
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);
+}