Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duck chess en passant FEN setup #849

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading