X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.cpp;h=fb17f209e3e4d24adeb9a45542f77f0b4fa8a3ba;hp=b4ccff5df3c053d1753934150f1c86deb0eb1232;hb=66d5c13a88f041247adf2ba62acdf936a6d6224e;hpb=721d5576811e5b641f73c07bdeb122d114cae7ca diff --git a/src/position.cpp b/src/position.cpp index b4ccff5d..fb17f209 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -204,11 +204,16 @@ void Position::from_fen(const string& fen) { while (fen[i] == ' ') i++; - // En passant square + // En passant square -- ignore if no capture is possible if ( i <= fen.length() - 2 && (fen[i] >= 'a' && fen[i] <= 'h') && (fen[i+1] == '3' || fen[i+1] == '6')) - st->epSquare = square_from_string(fen.substr(i, 2)); + { + Square fenEpSquare = square_from_string(fen.substr(i, 2)); + Color them = opposite_color(sideToMove); + if (attacks_from(fenEpSquare, them) & this->pieces(PAWN, sideToMove)) + st->epSquare = square_from_string(fen.substr(i, 2)); + } // Various initialisation for (Square sq = SQ_A1; sq <= SQ_H8; sq++)