Skip to content

Add ChessTB tablebase support - #1194

Open
noobpwnftw wants to merge 1 commit into
niklasf:masterfrom
noobpwnftw:add-chesstb-tablebases
Open

noobpwnftw wants to merge 1 commit into
niklasf:masterfrom
noobpwnftw:add-chesstb-tablebases

Conversation

@noobpwnftw

@noobpwnftw noobpwnftw commented Jun 8, 2026 •

Copy link
Copy Markdown

Adds chess.chesstb, a pure-Python reader for ChessTB endgame tables: WDL, DTZ, DTC, DTM and DTM50.

import chess
import chess.chesstb

with chess.chesstb.open_tablebase("/path/to/tables") as tb:
    board = chess.Board("8/8/8/5k2/8/8/1Q6/K7 w - - 0 1")
    result = tb.probe(board)  # All available metrics.
    distance = tb.probe_dtm(board)  # Signed distance from the side to move.

Tables are memory-mapped and decoded in blocks behind a shared cache. Tablebase supports concurrent probes, castling tables, opposing pawn pairs, en passant and reconstruction of omitted frames. DTC and DTM50 packs supply their embedded DTZ and DTM values when present. There are no new required dependencies; installed lz4 is used for faster WDL decoding.

Pawn-slice indexes use bitsets with the same numbering as the C++ generator. Index construction is synchronized per material. For the six-pawn opposing-pair material, construction takes 0.80 seconds instead of 151 seconds locally; the complete 152.7-million-cell bitmap and rank directory match the original implementation exactly.

Includes API documentation, fixture tables and 31 tests in ChesstbTestCase. All pass locally, including enumeration checks for pawn indexes and concurrent index construction. Existing validation against the C++ prober covered all 145 shipped materials up to five pieces, with additional checks for clocked metrics, dropped frames, loss-only tables and en passant.

ChessTB DTZ values are plain distances; unlike Syzygy's encoding, their magnitude does not carry the cursed/blessed WDL class. DTC returns (pawn pushes owed, signed plies) at the requested halfmove clock.

@noobpwnftw
noobpwnftw force-pushed the add-chesstb-tablebases branch 7 times, most recently from a252d4c to 228bac6 Compare July 1, 2026 01:08
@noobpwnftw
noobpwnftw force-pushed the add-chesstb-tablebases branch 22 times, most recently from 836a63f to 838e047 Compare August 15, 2026 02:34
@noobpwnftw
noobpwnftw force-pushed the add-chesstb-tablebases branch from 838e047 to 661cc2e Compare August 16, 2026 16:17
@noobpwnftw
noobpwnftw force-pushed the add-chesstb-tablebases branch 18 times, most recently from 2d82206 to 1f3a291 Compare August 26, 2026 14:22
@noobpwnftw
noobpwnftw force-pushed the add-chesstb-tablebases branch 6 times, most recently from 534e1b8 to 25a5747 Compare September 5, 2026 14:49
@noobpwnftw
noobpwnftw force-pushed the add-chesstb-tablebases branch 4 times, most recently from 07b6259 to c4484e8 Compare September 25, 2026 03:23
Add chess.chesstb for WDL, DTZ, DTC, DTM and DTM50 probing, with
memory-mapped tables, block caching and concurrent reads. Support
castling tables, opposing pawn pairs and reconstruction of omitted frames.

Build pawn-slice indexes with bitsets and per-material locks. Include
API documentation, fixture tables and tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant