From 7e541a40ed98c54c17ad50aebeff504fadd397e6 Mon Sep 17 00:00:00 2001 From: rektdie Date: Tue, 9 Apr 2024 12:02:27 +0200 Subject: [PATCH] bugfix in IsPinned function --- source/movegen.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/source/movegen.cpp b/source/movegen.cpp index d1d0b44..0e5a3b1 100644 --- a/source/movegen.cpp +++ b/source/movegen.cpp @@ -346,12 +346,11 @@ static Bitboard SliderRaysToSquare(int attacker, int target) { int direction = GetDirection(attacker, target); if (direction) { - while (attacker <= target) { + while (attacker != target) { ray.SetBit(attacker); attacker += direction; } } - 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 directionToKing = GetDirection(square, kingSquare); - if (SliderRaysToSquare(square, kingSquare).PopCount() != 2) { + if ((SliderRaysToSquare(square, kingSquare) & board.occupied).GetBoard()) { return false; }