X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.cpp;h=325ffd1114892aa0e4f1598acc74bc877d430adf;hp=9f5816d70b1326919867959e077329cb29215bcc;hb=de269ee18e78bc59f30996be71820b7f8af09edc;hpb=dc4655e1f9b77910afc6521c1b87661389b44e06 diff --git a/src/position.cpp b/src/position.cpp index 9f5816d7..325ffd11 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -176,8 +176,9 @@ Position& Position::set(const string& fenStr, bool isChess960, StateInfo* si, Th 4) En passant target square (in algebraic notation). If there's no en passant target square, this is "-". If a pawn has just made a 2-square move, this - is the position "behind" the pawn. This is recorded regardless of whether - there is a pawn in position to make an en passant capture. + is the position "behind" the pawn. This is recorded only if there is a pawn + in position to make an en passant capture, and if there really is a pawn + that might have advanced two squares. 5) Halfmove clock. This is the number of halfmoves since the last pawn advance or capture. This is used to determine if a draw can be claimed under the @@ -254,7 +255,8 @@ Position& Position::set(const string& fenStr, bool isChess960, StateInfo* si, Th { st->epSquare = make_square(File(col - 'a'), Rank(row - '1')); - if (!(attackers_to(st->epSquare) & pieces(sideToMove, PAWN))) + if ( !(attackers_to(st->epSquare) & pieces(sideToMove, PAWN)) + || !(pieces(~sideToMove, PAWN) & (st->epSquare + pawn_push(~sideToMove)))) st->epSquare = SQ_NONE; } else