bugfix in IsPinned function

This commit is contained in:
rektdie committed 2024-04-09 12:02:27 +02:00
1 parent 9bff7fa8b4
commit 7e541a40ed
1 file changed
+2 -3
+2 -3
View File
@@ -346,12 +346,11 @@ static Bitboard SliderRaysToSquare(int attacker, int target) {
int direction = GetDirection(attacker, target); int direction = GetDirection(attacker, target);
if (direction) { if (direction) {
while (attacker <= target) { while (attacker != target) {
ray.SetBit(attacker); ray.SetBit(attacker);
attacker += direction; attacker += direction;
} }
} }
return ray; return ray;
} }
@@ -382,7 +381,7 @@ static bool IsPinned(Board &board, int square, int color) {
int kingSquare = (board.colors[color] & board.pieces[King]).getLS1BIndex(); int kingSquare = (board.colors[color] & board.pieces[King]).getLS1BIndex();
int directionToKing = GetDirection(square, kingSquare); int directionToKing = GetDirection(square, kingSquare);
if (SliderRaysToSquare(square, kingSquare).PopCount() != 2) { if ((SliderRaysToSquare(square, kingSquare) & board.occupied).GetBoard()) {
return false; return false;
} }