bugfix: en passant was always possible in check evasions

This commit is contained in:
rektdie committed 2024-04-15 10:48:05 +02:00
1 parent ff0c0c785a
commit 5f77c88c85
1 file changed
+13 -2
+13 -2
View File
@@ -879,10 +879,21 @@ static void GenCheckEvasions(Board &board, bool color) {
if (type == Pawn) {
pushes |= getPawnPushes(square, color, board.occupied) & pushMask;
// Checking for en passant capture
if ((pawnAttacks[color][square]
& Bitboard::GetSquare(board.enPassantTarget)).GetBoard()) {
Bitboard attackedSquare = pawnAttacks[color][square]
& Bitboard::GetSquare(board.enPassantTarget);
if (attackedSquare.GetBoard()) {
// Checking if it's legal
if (IsLegalEnPassant(board, square)) {
int direction = color ? south : north;
int targetSquare = captureMask.getLS1BIndex() + direction;
captureMask.SetBit(targetSquare);
if ((attackedSquare & pushMask).GetBoard()
|| (attackedSquare & captureMask).GetBoard()) {
board.AddMove(Move(square, board.enPassantTarget, epCapture));
}
captureMask.PopBit(targetSquare);
}
}
} else {
pushes |= getPieceAttacks(square, type, color, board.occupied.GetBoard()) & pushMask;
}