From 55ce07b773b1b57faf65d9591b199b350868a933 Mon Sep 17 00:00:00 2001 From: Tomasz Sobczyk Date: Sat, 3 Apr 2021 16:15:51 +0200 Subject: [PATCH] Add additional checks for en-passant possiblity when fixing the erroneus ep flag from a fen. --- src/extra/nnue_data_binpack_format.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/extra/nnue_data_binpack_format.h b/src/extra/nnue_data_binpack_format.h index 453169dd..0b1ac0aa 100644 --- a/src/extra/nnue_data_binpack_format.h +++ b/src/extra/nnue_data_binpack_format.h @@ -6116,6 +6116,26 @@ namespace chess [[nodiscard]] inline bool Position::isEpPossibleColdPath(Square epSquare, Bitboard pawnsAttackingEpSquare, Color sideToMove) const { + if (pieceAt(epSquare) != Piece::none()) + { + return false; + } + + const auto forward = + sideToMove == chess::Color::White + ? FlatSquareOffset(0, 1) + : FlatSquareOffset(0, -1); + + if (pieceAt(epSquare + forward) != Piece::none()) + { + return false; + } + + if (pieceAt(epSquare + -forward) != Piece(PieceType::Pawn, !sideToMove)) + { + return false; + } + // only set m_epSquare when it matters, ie. when // the opposite side can actually capture for (Square sq : pawnsAttackingEpSquare)