Skip to content

Commit

Permalink
Fix duck chess en passant FEN setup
Browse files Browse the repository at this point in the history
Closes #832.
  • Loading branch information
ianfab committed Dec 11, 2024
1 parent 26a168d commit e9c8a56
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/position.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
5 changes: 5 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e9c8a56

Please sign in to comment.