Skip to content

Commit 95803fc

Browse files
committed
Artificially limit syzygy ab search after relaxing bound
1 parent a41c3c8 commit 95803fc

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

chess/syzygy.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,6 +1561,13 @@ def probe_ab(self, board: chess.Board, alpha: int, beta: int, threats: bool = Fa
15611561
if board.castling_rights:
15621562
raise KeyError(f"syzygy tables do not contain positions with castling rights: {board.fen()}")
15631563

1564+
# Probing resolves captures, so sometimes we can obtain results for
1565+
# positions that have more pieces than the maximum number of supported
1566+
# pieces. We artificially limit this to one additional level, to
1567+
# make sure search remains somewhat bounded.
1568+
if chess.popcount(board.occupied) > TBPIECES + 1:
1569+
raise KeyError(f"syzygy tables support up to {TBPIECES} pieces, not {chess.popcount(board.occupied)}: {board.fen()}")
1570+
15641571
# Special case: Variant with compulsory captures.
15651572
if self.variant.captures_compulsory:
15661573
if board.is_variant_win():

0 commit comments

Comments
 (0)