Skip to content

Commit

Permalink
Artificially limit syzygy ab search after relaxing bound
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Jul 4, 2024
1 parent a41c3c8 commit 95803fc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions chess/syzygy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,13 @@ def probe_ab(self, board: chess.Board, alpha: int, beta: int, threats: bool = Fa
if board.castling_rights:
raise KeyError(f"syzygy tables do not contain positions with castling rights: {board.fen()}")

# Probing resolves captures, so sometimes we can obtain results for
# positions that have more pieces than the maximum number of supported
# pieces. We artificially limit this to one additional level, to
# make sure search remains somewhat bounded.
if chess.popcount(board.occupied) > TBPIECES + 1:
raise KeyError(f"syzygy tables support up to {TBPIECES} pieces, not {chess.popcount(board.occupied)}: {board.fen()}")

# Special case: Variant with compulsory captures.
if self.variant.captures_compulsory:
if board.is_variant_win():
Expand Down

0 comments on commit 95803fc

Please sign in to comment.