diff --git a/src/position.cpp b/src/position.cpp index 5278c0157..81fa3c774 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -438,14 +438,14 @@ Position& Position::set(const Variant* v, const string& fenStr, bool isChess960, // 2) // a) side to move have a pawn threatening epSquare // b) there is an enemy pawn one or two (for triple steps) squares in front of epSquare - // c) there is no piece on epSquare or behind epSquare + // c) there is no (non-wall) piece on epSquare or behind epSquare if ( (var->enPassantRegion & epSquare) && ( !var->fastAttacks || (var->enPassantTypes[sideToMove] & ~piece_set(PAWN)) || ( pawn_attacks_bb(~sideToMove, epSquare) & pieces(sideToMove, PAWN) && ( (pieces(~sideToMove, PAWN) & (epSquare + pawn_push(~sideToMove))) || (pieces(~sideToMove, PAWN) & (epSquare + 2 * pawn_push(~sideToMove)))) - && !(pieces() & (epSquare | (epSquare + pawn_push(sideToMove))))))) + && !((pieces(WHITE) | pieces(BLACK)) & (epSquare | (epSquare + pawn_push(sideToMove))))))) st->epSquares |= epSquare; } } diff --git a/test.py b/test.py index bef4e5f6e..03f656b64 100644 --- a/test.py +++ b/test.py @@ -470,6 +470,11 @@ def test_get_fen(self): result = sf.get_fen("pocketknight", "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR[Nn] w KQkq - 0 1", ["N@e4"]) self.assertEqual(result, "rnbqkbnr/pppppppp/8/8/4N3/8/PPPPPPPP/RNBQKBNR[n] b KQkq - 0 1") + # duck chess en passant + fen = "r1b1k3/pp3pb1/4p3/2p2p2/2PpP2q/1P1P1P2/P1K1*3/RN1Q2N1 b q e3 0 17" + result = sf.get_fen("duck", fen, []) + self.assertEqual(result, fen) + # SFEN result = sf.get_fen("shogi", SHOGI, [], False, True) self.assertEqual(result, SHOGI_SFEN)