Skip to content

Commit

Permalink
Do not eagerly check syzygy max pieces (fixes #1093)
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Jul 4, 2024
1 parent 3829d26 commit a41c3c8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions chess/syzygy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1546,6 +1546,8 @@ def probe_wdl_table(self, board: chess.Board) -> int:
try:
table = typing.cast(WdlTable, self.wdl[key])
except KeyError:
if chess.popcount(board.occupied) > TBPIECES:
raise KeyError(f"syzygy tables support up to {TBPIECES} pieces, not {chess.popcount(board.occupied)}: {board.fen()}")
raise MissingTableError(f"did not find wdl table {key}")

self._bump_lru(table)
Expand All @@ -1558,8 +1560,6 @@ def probe_ab(self, board: chess.Board, alpha: int, beta: int, threats: bool = Fa
raise KeyError(f"tablebase has been opened for {self.variant.uci_variant}, probed with: {board.uci_variant}")
if board.castling_rights:
raise KeyError(f"syzygy tables do not contain positions with castling rights: {board.fen()}")
if chess.popcount(board.occupied) > TBPIECES:
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:
Expand Down

0 comments on commit a41c3c8

Please sign in to comment.