mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 17:19: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:
parent
807844eab1
commit
cc974fa7a4
1 changed files with 7 additions and 2 deletions
|
@ -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++)
|
||||
|
|
Loading…
Add table
Reference in a new issue