fixed a bug in IsLegalEnpassant function

This commit is contained in:
rektdie committed 2024-04-08 22:03:13 +02:00
1 parent 36db22ea6b
commit e02940010a
1 file changed
+5 -5
+5 -5
View File
@@ -400,9 +400,9 @@ static bool IsLegalEnPassant(Board &board, int square) {
// Looking for horizontal checks // Looking for horizontal checks
if (!(kingSquare.GetBoard() & files[A])) { if (!(kingSquare.GetBoard() & files[A])) {
int currentSq = kingSquare.getLS1BIndex() + east; int currentSq = kingSquare.getLS1BIndex() + west;
while (!Bitboard(files[A]).IsSet(currentSq)) { while (!Bitboard(files[H]).IsSet(currentSq)) {
if (newOccupancy.IsSet(currentSq)) { if (newOccupancy.IsSet(currentSq)) {
int attackerColor = board.GetPieceColor(currentSq); int attackerColor = board.GetPieceColor(currentSq);
int attackerType = board.GetPieceType(currentSq); int attackerType = board.GetPieceType(currentSq);
@@ -411,9 +411,9 @@ static bool IsLegalEnPassant(Board &board, int square) {
|| attackerType == Bishop || attackerType == Queen)) { || attackerType == Bishop || attackerType == Queen)) {
return false; return false;
} }
return true; break;
} }
currentSq += east; currentSq += west;
} }
} }
@@ -429,7 +429,7 @@ static bool IsLegalEnPassant(Board &board, int square) {
|| attackerType == Bishop || attackerType == Queen)) { || attackerType == Bishop || attackerType == Queen)) {
return false; return false;
} }
return true; break;
} }
currentSq += east; currentSq += east;
} }