ChessTB is a chess endgame tablebase generator that supports five metrics. Tables can be stored in full or reduced form. Reduced forms include a dropped side-to-move (STM) frame, loss-only distances, and relaxed WDL or DTZ. See Shrink and Transcribe.
- WDL: 50-move-rule-aware win/draw/loss with cursed/blessed classes.
- DTZ: distance-to-zeroing (plies to the next capture, promotion, or pawn push), accounting for the 50-move rule without class offsets (see Format).
- DTC: distance-to-conversion at any halfmove clock, measured first in pawn pushes: how many pushes the winning side still needs before a capture or promotion, and how many plies remain until the next zeroing move on that line. DTZ is embedded as the unbounded row (see DTC).
- DTM: distance-to-mate, ignoring the 50-move rule.
- DTM50: distance-to-mate at any halfmove clock, packed with DTM into one file (see Universal DTM).
The correctness of the generator and the prober is proved in CORRECTNESS.md.
Available mirrors:
ftp://chessdb:chessdb@ftp.chessdb.cn/pub/chesstb/
rsync://ftp.chessdb.cn/ftp/pub/chesstb/
hf://buckets/chesstb/chesstb/
https://chesstb.lichess.ovh/tables/
In the table below, ... means a build is in progress, --- means a build is
not planned, and Op1 denotes one opposing pawn pair.
Shipping tables are organized by metric in wdl/, dtz/, dtc/, dtm/, and
dtm50/. dtm50/ supersedes dtm/; dtc/ supersedes dtz/ for pawnful
materials. The same layout applies under full/ for raw generator output and
castling/ for tables with castling rights.
Shipping size breakdown, including castling tables:
| Material | wdl/ |
dtz/ |
dtc/ |
dtm/ |
dtm50/ |
|---|---|---|---|---|---|
| 3 (Pawnless) | 360 B | 8.91 KiB | N/A | 8.91 KiB | 10.7 KiB |
| 3 (Pawnful) | 4.07 KiB | 1.95 KiB | 6.82 KiB | 7.07 KiB | 14.8 KiB |
| 4 (Pawnless) | 240 KiB | 1.99 MiB | N/A | 2.22 MiB | 8.08 MiB |
| 4 (Pawnful) | 541 KiB | 532 KiB | 3.12 MiB | 3.73 MiB | 12 MiB |
| 5 (Pawnless) | 46.5 MiB | 272 MiB | N/A | 430 MiB | 2.15 GiB |
| 5 (Pawnful) | 159 MiB | 263 MiB | 1.01 GiB | 1.32 GiB | 4.47 GiB |
| 6 (Pawnless) | 6.88 GiB | 26.9 GiB | N/A | 53 GiB | 263 GiB |
| 6 (Pawnful) | 28.6 GiB | 48.2 GiB | 177 GiB | 246 GiB | 861 GiB |
| 7 (Pawnless) | 693 GiB | 1.89 TiB | N/A | 5.13 TiB | --- |
| 7 (Pawnful) | 3.5 TiB | 5.82 TiB | --- | 31.8 TiB | --- |
| Total (≤6) | 35.7 GiB | 75.6 GiB | 178 GiB | 301 GiB | 1.1 TiB |
| Total (≤7) | 4.21 TiB | 7.79 TiB | --- | 37.2 TiB | --- |
| 8 (Op1) | 5.83 TiB | 7.6 TiB | --- | --- | --- |
Tablebase filenames are case-sensitive. Use a case-sensitive filesystem for tablebase files and preserve their exact capitalization.
On Windows (NTFS), open PowerShell as Administrator and enable case sensitivity on an empty tablebase folder before generating or downloading tables:
mkdir C:\chesstb
fsutil.exe file setCaseSensitiveInfo C:\chesstb enableOn macOS, use a volume formatted as APFS (Case-sensitive). In Disk Utility,
select an existing APFS volume, click Add Volume, name the new volume
chesstb, choose APFS (Case-sensitive) as its format, and click Add.
Use /Volumes/chesstb/ for storing tables.
make
make toolsThe build produces:
chesstb: generatorshrink: postprocessor for shipping-format filestranscribe: re-encoder for shipping-format files
make lib writes the prober as drop-in sources in namespace chesstb to
obj/libchesstb/: chesstb.h and chesstb.cpp. make tools builds the
tools/probe_fen diagnostic utility (see Probe); the tools are
examples that use the library. The build has no dependencies beyond the
vendored sources; make lib and make tools also need python3.
./chesstb -r KQK
./chesstb -r KBPK --builddtc
./chesstb -r KBNK --builddtm
./chesstb -r KBNK --builddtm50
./chesstb -r KBPK --mem 64 -t 8
./chesstb --enumerate 5 > five.txt
./chesstb --list five.txtOutputs:
wdl/<material>.lzwdtz/<material>.lzdtzdtz/<material>.infodtc/<material>.lzdtc(with--builddtc; pawnful materials only)dtc/<material>.info(with--builddtc; pawnful materials only)dtm/<material>.lzdtm(with--builddtmor--builddtm50)dtm/<material>.info(with--builddtmor--builddtm50)dtm50/<material>.lzdtm50(with--builddtm50)dtm50/<material>.info(with--builddtm50)
Options:
| Flag | Meaning |
|---|---|
-r LIST |
comma-separated materials (-r KQK,KRK) |
--list FILE |
newline-separated materials; ; and # start comments |
-t N |
worker threads (default: hardware concurrency) |
--mem MiB |
soft cap on resident memory (0 = unbounded; see Memory) |
--cache MiB |
decoded-block cache budget shared by the sub-table probe readers (default: 64) |
--wdl/--dtz/--dtc/--dtm/--dtm50 DIR |
additional search directory for existing tables and sub-tables; repeatable; output always goes to ./wdl/, ./dtz/, ./dtc/, ./dtm/, or ./dtm50/ |
--tmp DIR |
scratch directory for spilled groups and checkpoints (default: ./tmp/) |
--builddtc |
also build DTC for pawnful materials only (see DTC) |
--builddtm |
also build the standalone DTM table |
--builddtm50 |
also build DTM50 (implies the DTM pass) |
--probe |
read DTM/DTM50 sub-tables directly instead of using flat-decompressed temporary files; uses less scratch space but reads more slowly |
--fleet |
cooperative multi-process mode: acquire a per-material flock, skip materials owned by another worker, and wait rather than abort when sub-tables are not yet ready |
--enumerate N |
print canonical material names with ≤ N total pieces |
--estimate |
print the working-set estimate and exit |
--info PATHS |
dump .info files and exit; accepts globs (--info dtz/*.info) |
The generator expands each requested material to include its capture and
promotion dependencies, then processes them in dependency order. The DTZ pass
always runs; WDL is projected from its output. --builddtm50 runs DTM first and
folds it into DTM50. --builddtm adds the standalone DTM table without
requesting DTM50.
Existing output is skipped. Each pass checks one output file for completion. For
the DTZ pass, that file is wdl/<material>.lzw; delete it to force a rebuild.
--mem MiB sets a soft cap on resident memory usage; --mem 0 removes the cap.
Positive values enable paging of groups through --tmp. Values below 64 are
raised to 64 because paging requires enough memory for at least one group. The
same budget applies to both generation and compression phases.
Use --estimate before a large run:
./chesstb --estimate -r KQRBKQRN
./chesstb --estimate -r KQRBKQNP --builddtm
./chesstb --estimate -r KQRBKQNP --builddtm50The report first shows the index geometry: position count, full resident size across both colors, and the pager's slice and group layout. It then gives peak residency for each pass at three fusion scopes, in groups and bytes:
- per-dispatch: one group at a time. This is the minimum usable
--mem. - per-mirror-pair: one pawn slice and its file mirror for their full trajectory.
- per-batch: one complete topological batch of pawn slices. This is the
--mem 0peak.
Initialization and building have separate peaks; the report gives both.
--builddtc and --builddtm50 add a per-dispatch line for their passes, which
page by budget or halfmove-clock layer. Saving works one block at a time within
the same budget.
The minimum memory requirement follows from the index geometry alone, so
--estimate quantifies it for each material. Pawnful materials have larger
indexes because they have only file-mirror symmetry, but their pawns give the
pager finer slices. For the pawnless 8-man KQRBKQRN, the minimum is 18 groups
(2.25 TiB), compared with a full resident footprint of 115.5 TiB; --builddtm50
raises it to 19 groups.
SIGINT and SIGTERM cause the generator to stop at the next safe iteration
boundary, flush its state, write a pass-specific checkpoint under --tmp, and
exit with status 130.
SIGQUIT instead schedules a clean exit at the next material boundary, where no
checkpoint is needed. SIGHUP cancels any pending exit request, including one
from SIGINT or SIGTERM, provided it has not yet been handled.
To resume from a checkpoint, rerun the same command with the saved state in
place. Delete the checkpoint to start over or before changing --mem.
./tools/probe_fen "8/8/8/5k2/8/8/1Q6/K7 w"
./tools/probe_fen --children "8/8/8/6B1/3k4/3B4/p7/1K6 w - - 0 1"
./tools/probe_fen --wdl ./wdl --dtz ./dtz --dtm50 ./dtm50 "8/8/8/8/4k3/8/Q7/K7 w"
./tools/probe_fen --dtm50 ./dtm50 "8/8/8/4k3/8/8/Q7/K7 w - - 50 30"
./tools/probe_fen --dtc ./dtc "8/8/8/k7/8/8/K4P2/8 w - - 0 1"probe_fen reports WDL, DTZ, DTC, DTM, and DTM50 for a FEN. It includes a field
only when the required table is available. DTC is displayed as
class/order/value; its class reflects the supplied clock, not the
clock-independent WDL class. See DTC. Every table-directory flag
may be repeated.
The FEN halfmove clock selects the DTM50 layer and DTC budget. A missing or
invalid clock is treated as 0; a clock of 100 or more yields DRAW. --children
passes the resulting clock to each child (zeroing → 0, quiet → parent+1).
A FEN with castling rights can be probed only with a table that includes those rights (see Castling rights). If no such table is available on disk, the probe reports that no table was found.
./shrink wdl dtz dtc dtm dtm50
./shrink wdl/KQK.lzw dtz/KQK.lzdtz dtm/KQK.lzdtm dtm50/KQK.lzdtm50
./shrink dtc/KBPK.lzdtc
./shrink --dry-run dtz/*
./shrink --out output wdl/* dtz/* dtc/* dtm/* dtm50/*shrink rewrites files in place by default, dropping the larger compressed STM
frame when it can be reconstructed at probe time (see Format).
In a castling table, the WDL frame of a side that holds a castling right is never dropped, since rebuilding it would need exact boundary codes from another table. The other frame is dropped instead, or none if both sides hold rights.
Arguments may be individual table files or generated table directories. Files
are identified by their magic bytes, so mixed shell globs are safe: .info
metadata, already-shrunk files, loss-only files (see Transcribe),
and non-derivable files are skipped. -n/--dry-run parses each file and
reports the size it would shrink to without writing anything, then prints a
grand total.
--out DIR leaves the inputs untouched and writes results under DIR instead.
Since the argument list is usually a glob spanning several table directories,
DIR is one flat directory keyed by filename alone (the extension already
distinguishes the table types). Tables that cannot be shrunk are copied there
unchanged; non-table files are not copied.
./transcribe --out output --dtz dtz --dtm dtm --dtm50 dtm50 -r KQK,KRK
./transcribe --out output --do-wdl --list five.txt --block 32
./transcribe --out output --do-wdl --relaxed --list five.txt
./transcribe --out output --dtc dtc --loss-only --list five.txt
./transcribe --out output --dtm50 dtm50 --extract-dtm --list five.txt
./transcribe --out output --dtz dtz --relaxed --shrink --fleet --list seven.txttranscribe re-encodes a finished table in another shipping format. The source
file contains the classified cells, value histogram, and index permutation, so
the tool can change the block layout, permutation, ranks, and compression
without solving the table again. It writes to --out and leaves the source
mapped during the run.
| Flag | Meaning |
|---|---|
-r LIST / --list FILE |
materials, as for the generator |
--out DIR |
output directory; must differ from the input directory |
--wdl DIR |
additional WDL search directory; repeatable (default ./wdl/) |
--do-wdl |
transcribe the WDL table itself |
--dtz/--dtc/--dtm/--dtm50 DIR |
transcribe the specified metric from DIR |
--extract-dtz |
transcribe DTC's embedded DTZ as a standalone table; automatic with --loss-only |
--extract-dtm |
transcribe DTM50's embedded DTM as a standalone table; automatic with --loss-only |
--loss-only |
emit loss-only frames (see below) |
--shrink |
transcribe both STM frames, then drop one payload when the other frame can reconstruct it |
--relaxed |
emit relaxed WDL or DTZ; symmetric materials use loss-only for requested distance tables, while other asymmetric distance types are rejected (see below) |
--block KiB |
output block size (default: the metric's default block size; capped at 64 for WDL) |
--samples N |
blocks compressed per permutation candidate (default: the metric's default sample count) |
-t N |
worker threads |
--cache MiB |
decoded-block budget shared by the sources (default: 64) |
--fleet |
cooperate through per-material locks and skip finished output |
--tmp DIR |
scratch directory for spilled blocks |
A dropped frame has no payload and passes through unchanged. A distance table needs its WDL companion for the class of every color being re-encoded. Use the full tables as input when a reduced source lacks a required frame.
--loss-only writes distance tables that store distances only for loss-class
cells. Win values become don't-cares. The prober reconstructs them with the same
one-ply minimax used for a dropped color. WDL is never loss-only because it
provides the classes used during reconstruction.
Loss-only storage and an STM drop cannot be combined: the dropped color's losses
could depend on omitted wins. shrink therefore skips loss-only files, and
transcribe rejects converting a dropped source to loss-only. Symmetric
materials are exempt because their second frame mirrors the first.
An STM drop removes one whole frame; loss-only instead thins every stored frame. It is the reduction for symmetric materials, which store only one frame and so have none to drop.
For DTC and DTM50, --loss-only implies --extract-dtz or --extract-dtm:
the extracted table is written first and the pack reuses its permutation.
Relaxation treats selected cells as don't-cares. WDL and DTZ use different rules
to select them. Relaxed tables may also drop an STM frame; shrink preserves
the relaxed flag. Relaxed WDL cannot be transcribed again. Relaxed DTZ can be
transcribed with --relaxed or --loss-only because neither reads the freed
values.
The probe takes the best class a capture or promotion reaches, read from the
sub-table, and returns the larger of that bound and the stored code. A cell whose
class the bound already reaches may therefore store any lower code; every other
cell stores its own. For example, a KQKR win by rook capture reaches a KQK
win, so its cell is free to take whatever code compresses best.
Boundary codes rank between their class and the adjacent cursed class
(BOUNDARY_LOSS just above LOSE, BOUNDARY_WIN just below WIN), so the same
maximum keeps a genuine boundary marker and replaces boundary filler. Boundary
cells themselves are never capped.
Encoding. The encoder tries two fills for freed cells and keeps the smaller compressed block. Run-stitch extends an adjacent run, which works well for locally constant values. relz continues an earlier occurrence of the last four committed bytes, the minimum LZ4 match, which works well for strided data.
Transcription needs full one-move sub-tables. The permutation search uses the capped cells. Relaxed WDL cannot be processed twice because the second pass would measure caps against the first pass's fill.
A winning cell has DTZ 1 when some zeroing move (a capture, promotion or pawn move) keeps its WDL class. Relaxed DTZ omits those values, and the probe tests the zeroing moves first. The test reads only WDL classes, never a child DTZ. Losses are always stored.
Transcription needs the full WDL closure and the material's own WDL in full form;
the DTZ source may already be relaxed or dropped. Relaxed DTZ can be combined
with an STM drop. For symmetric materials --relaxed writes loss-only distance
tables instead; for asymmetric ones it supports only WDL and DTZ.
Positions map to a storage index built for paging: king and pawn dimensions carry the slice structure, so the compressor's permutation search is restricted to the remaining piece classes (identical pieces within a class are combinationally ranked), and gaps are skipped at block granularity rather than compacted into a denser index. The chosen permutation is stored per color in the file header.
WDL stores a 4-bit class code per position, with two codes per byte, compressed using LZ4-HC and a dictionary trained on the table itself (the dictionary is omitted for tables with fewer than 256 blocks). Distance tables map each value to a frequency-sorted rank, encoded in 1 byte (≤256 ranks) or 2 bytes, and compress those rank streams with LZMA. DTZ ranks raw ply distances exactly, halving only cursed/blessed plies in the 1-byte tier. This can lose up to one ply but does not affect play because those distances are past the 50-move horizon. DTM halves every value losslessly via its parity invariant (WIN odd, LOSE even).
Blocks compress independently. WDL uses 64 KiB blocks; DTZ, DTC, DTM, and DTM50 use 1 MiB blocks. A per-color offset section locates each block.
Each .info file contains symmetry-expanded, orbit-weighted W/D/L/illegal
counts per stored color, plus that color's longest win and its FEN. The orbit
weight is each canonical position's true multiplicity (2 under file-mirror
symmetry; 4 or 8 under the pawnless dihedral group, depending on king-slice
stabilizers; 1 for castling tables, which use no symmetry), so for each color
W + D + L + illegal equals the table's weighted domain total. Since WDL is
projected from the DTZ pass, it has no .info file of its own; its counts are
included in the DTZ .info file.
Apart from en passant, decoding stays within one material: DTZ/DTC/DTM/DTM50 read classes from the material's own WDL companion, and WDL needs no companion, so a full table decodes from its own files in O(1): one block read and one index lookup. When the FEN carries en-passant rights, each legal en-passant capture (at most two) adds a probe of that capture's sub-table. Sub-tables are needed only when generating a material or probing a dropped (see Shrink), loss-only, or relaxed frame.
Each color's frame begins with a flag byte: 0x80 indicates one value for the
whole domain, 0x40 a dropped frame, 0x20 losses only, and 0x10 a relaxed
frame (see Transcribe). The latter three require the prober to
reconstruct cells, so the generator does not accept them as sub-tables and
regenerates the tables instead.
A dropped frame is rebuilt by one-ply minimax over the retained frame: quiet children are read there directly, and captures and promotions read a sub-table. A loss-only frame rebuilds its wins the same way from the opponent's stored losses.
For WDL, the only ambiguity between WIN and CURSED_WIN arises when a child is at
the last ply allowed by the rule (dtz == 100) and its parent crosses the
50-move boundary. Two spare 4-bit codes (BOUNDARY_WIN, BOUNDARY_LOSS) mark
those positions; every other reader maps them to WIN/LOSE. Zeroing moves reset
the clock, so they do not cross this boundary and need no marker.
An .lzdtm50 file provides both unbounded DTM and exact 50-move-rule DTM50 for
any halfmove clock.
The 50-move rule makes DTM depend on the halfmove clock. Each material stores a layer for clocks 0 through 99, containing the optimal mate distance or DRAW if no winning line reaches a zeroing move in time.
Unbounded DTM. Along the halfmove-clock axis, each position's value is monotonically non-decreasing:
DTM ≤ DTM50(hmc=0) ≤ … ≤ DTM50(hmc=99)
The sequence ends in DRAW once no winning line fits within the remaining clock.
Packed layer 0 adds unbounded DTM, introducing at most one extra change point
per position; clock k uses layer k + 1. transcribe --extract-dtm writes
layer 0 as a standalone table.
Each layer derives its class from the WDL companion: layer 0 treats cursed/blessed results as decisive; hmc = 0 maps them to DRAW; hmc > 0 also maps routes that exceed the remaining clock to DRAW. Where DTM50 and WDL disagree (a WDL=WIN cell is drawn because too few plies remain), the draw-end hint records the difference.
Pack layout. All 101 layers are stored in one dtm50/<material>.lzdtm50
file (layer 0 contains unbounded DTM; layers 1..100 contain the halfmove-clock
layers). Since the value is constant or nearly so for most positions, each
position is classified within its block into one of four states, using 2 bits
per position:
- CONST: identical at every layer.
- SINGLE: one transition, encoded as
[h, r0, r1], where h ∈ [1, 100]. - DOUBLE: two transitions, encoded as
[h1, h2, r0, r1, r2]. - MULTI: three or more transitions, encoded as
[k, changepoint bitmap, k ranks].
Each non-CONST state has an "ends in DRAW" bit in the most significant bit of
the last h byte (or MULTI's k byte). When set, this bit allows the trailing
rank to be omitted and tells the decoder to return DRAW. Rank tables contain
only W/L values, ordered by how many layers each value appears in; DRAW and
ILLEGAL use no rank, so
all-DRAW/ILLEGAL blocks have no payload.
Embedded DTZ. The final change point to DRAW encodes DTZ. For a W/L position
with 2 ≤ dtz ≤ 100, the 50-move-rule result changes when zeroing no longer
fits within the remaining clock, at h = 102 - dtz. The endpoints require
special handling: h = 1 indicates a position already drawn at a fresh clock,
identifying the cursed/blessed band without specifying a distance. Positions
with dtz ≤ 1 never change. In that range, dtz = 0 means checkmate, which
move generation distinguishes from dtz = 1. The prober decodes the transition
alongside the value and combines it with the layer using minimax, so the packed
table provides DTZ everywhere except in the cursed/blessed band.
A prefix index over the state vector keeps lookups constant-time. All 101 layers take about 4× the storage of one layer, or about one-twenty-fifth that of 100 flat halfmove-clock tables.
./chesstb -r KBNK --builddtm50
./chesstb --estimate -r KBNK --builddtm50
./tools/probe_fen --children "8/8/8/4k3/8/8/Q7/K7 w - - 50 1"DTC measures distance-to-conversion, counting pawn pushes separately from waiting moves. A DTC probe returns two numbers for the supplied halfmove clock:
- order: the number of pawn pushes the winning side still needs before a conversion (a capture or a promotion). A push is irreversible progress that is not yet a conversion; the count resets at every conversion.
- value: the number of plies to the next zeroing move on that line, the same quantity measured by DTZ. At order 0, the next zeroing move is the conversion; at higher orders, it is the first of the remaining pawn pushes.
Order is optimized before value: a conversion without a pawn push beats a faster line that uses one. DTZ cannot express this because every pawn move has value 1. With two pawns against a king, DTZ may advance both in ten pushes; DTC can use a double push and promote one in four pushes.
Push budgets. Using fewer pushes can require more waiting moves. The table therefore stores layers indexed by push budget. Layer k allows the winning side to use at most k pawn pushes. Within a layer, values use DTZ semantics. A winning-side pawn push moves to the next lower layer; a losing-side push stays in the same layer.
The probe selects the smallest push budget whose waiting distance fits rule50.
If none fits, it returns DRAW. DTC therefore reports its own class: WIN or
LOSE with an order/value pair, or DRAW. This is separate from
clock-independent WDL.
Layers store only results settled by the 50-move rule. A win that exceeds the current clock belongs to a larger push budget; unresolved results use the unbounded row. Classes always come from the WDL companion.
Storage uses the same change-point format as Universal DTM: budgets count down from the largest, so the unbounded row sits at packed index 0 and each cell's DRAW run appears at the end, where the draw-end hint encodes it. Most cells are CONST because their optimal line has no pawn push.
Thirty-one rows suffice for up to 8 men (at most six pawns with five non-converting pushes each); the last is the embedded DTZ row.
The unbounded row is the DTZ table. As with DTM inside DTM50, generation
reads DTZ from dtz/ instead of solving it again, stores its raw ply values,
and reuses its layout. One .lzdtc file therefore answers both metrics,
including the cursed band. A pawnful material does not need a separate dtz/
file, and transcribe --extract-dtz can reproduce it byte for byte.
Pawnful only. Without pawn pushes to budget, the stack has just one layer, and every zeroing move is already a conversion. A pawnless pack would therefore duplicate the DTZ table.
Tables for materials with pawns on both sides grow quickly because each free pawn adds an independent dimension of about 48 squares. Many positions contain an opposing pawn pair: one white and one black pawn on the same file, with white below black and neither able to pass the other. Such a pair has only 120 joint placements (white on ranks 2..6, black strictly above on ranks 3..7 → 15 rank pairs × 8 files), compared with approximately 2,304 placements for a free white/black pawn pair. An opposing-pair table indexes the pair as a single 120-entry dimension.
Naming. Lowercase 'p' denotes the pair and appears once on each side to
show that both colors have a pawn. KQpKp represents white K+Q plus the pair's
white pawn, and black K plus the pair's black pawn. Its physical material is
KQPKP. At most one pair is allowed per material.
Size reduction. The pair pawns remain ordinary board pieces. Only their indexing changes, so a position has the same value in either table.
| Pair table | positions | resident | full material | positions | resident |
|---|---|---|---|---|---|
KpKp |
216,720 | 847 KiB | KPKP |
4,074,336 | 15.5 MiB |
KQpKp |
13,870,080 | 52.9 MiB | KQPKP |
260,757,504 | 995 MiB |
KRPpKRp |
39,649,935,360 | 148 GiB | KRPPKRP |
383,835,045,888 | 1.40 TiB |
The size reduction is approximately 19× when the pair is the only pawn
structure, and smaller when free pawns remain alongside it. For example,
KRPpKRp retains a free white pawn, giving a reduction of approximately 9.7×.
Domain. Pair pawns are indistinguishable from free pawns on the board, so the indexed pair is the first in lexicographic order by file and pawn ranks. Other cells are pruned, preserving a unique board-to-index mapping.
Transitions. Non-capturing moves by a pair pawn stay in the same 'p'
material. Captures leave it with one fewer piece:
- p → PP: any capture of a free piece, whether the captor is a free piece or
a pair member (diagonally or en passant). Both members join the child as free
pawns, so the child is the full free-pawn material minus the captured piece.
From
KQpKp, that isKPKP. - p → P: a pair member is itself captured (including en passant after a
double push). The surviving member becomes a free pawn. From
KQpKp, that isKQPKorKQKP.
A capture resolves into a full sub-table, converting any surviving pair
pawns to free pawns. KQpKp therefore depends on KPKP, KQPK, KQKP, and
their closures, but not the equally sized KQPKP. Only KQpKp itself is a pair
table in its 26-configuration plan.
A free-pawn promotion preserves the pair, so KPpKp depends on
KQpKp/KRpKp/KBpKp/KNpKp. A table without free pawns, such as KQpKp,
has no pair-table dependency.
./chesstb --estimate -r KQpKp
./chesstb -r KQpKp --builddtm50
./tools/probe_fen --wdl ./wdl "8/8/8/8/1p6/1P6/3k4/K6Q w"A piece-only table cannot distinguish positions with castling rights. A
castling table indexes the rights with the pieces. Lowercase 'r' denotes a
rook that retains castling rights, together with its king. KrK has the same
physical material as KRK. KrrK represents an unmoved king with both rooks on
their starting squares, and KrrKrr represents that configuration for both
sides. Each side may have at most two rights. Starting files and each rook's
side of the king are index dimensions, not part of the material name. One table
covers every arrangement, including the general Chess960/DFRC case.
The constrained king and rooks form one 56-entry dimension per side instead of
separate 64-square dimensions. Thus KrKr has 56 × 56 = 3,136 placements.
Castling rights can only decrease, so a castling table depends on its
counterpart without castling rights. A king move, castling move, or rook move
turns r into an ordinary R: KrrK becomes KRrK or KRRK. Capturing the
rook removes its right, so KrrK becomes KrK. A move can do both; a rook
capturing the enemy rook along its file leaves KRK.
./chesstb --estimate -r KrrKrr
./chesstb -r KrK --builddtm --builddtm50 --builddtc
./tools/probe_fen --wdl ./wdl --dtz ./dtz "8/8/8/8/8/7k/8/KR6 w K -"src/chess/ board, moves, FEN, indexing primitives
src/egtb/ generators, compression, slicing, paging
src/probe/ standalone probe library
src/shrink/ shipping-format shrinker
src/transcribe/ shipping-format re-encoder
src/system/ platform shims
src/util/ allocation, threading, compression helpers
tools/ diagnostic tools
lib/ vendored LZ4, LZMA, zstd (xxHash and dict trainer)