1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-05-02 09:39:36 +00:00

Fix en-passant parsing from fen string

According to standard en-passant is recorded in fen string regardless
of whether there is a pawn in position to make an en passant capture.

Instead internally we set ep square only if the pawn can be captured.
So teach from_fen() to correctly handle this difference.

Bug reported and fixed by Justin Blanchard.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2010-01-06 09:58:41 +01:00
parent 807844eab1
commit cc974fa7a4

View file

@ -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<PAWN>(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++)