Gaviota endgame tablebase probing

This module is experimental and does not yet come with a pure Python fallback. Instead you have to build and install a shared library:

git clone
cd Gaviota-Tablebases
sudo make install

Gaviota tablebases provide WDL (win/draw/loss) and DTM (depth to mate) information for all endgame positions with up to 5 pieces. Positions with castling rights are not included.

chess.gaviota.open_tablebases(directory=None, libgtb=None, LibraryLoader=<ctypes.LibraryLoader object>)

Opens a collection of tablebases for probing.

Currently the only access method is via the shared library libgtb. You can optionally provide a specific library name or a library loader. The shared library has global state and caches, so only one instance can be open at a time.

class chess.gaviota.NativeTablebases(directory, libgtb)

Provides access to Gaviota tablebases via the shared library libgtb.


Loads .gtb.cp4 tables from a directory.


Probes for depth to mate information.

Returns None if the position was not found in any of the tables.

Otherwise the absolute value is the number of half moves until forced mate. The value is positive if the side to move is winning, otherwise it is negative.

In the example position white to move will get mated in 10 half moves:

>>> with chess.gaviota.open_tablebases("data/gaviota") as tablebases:
...     tablebases.probe_dtm(chess.Board("8/8/8/8/8/8/8/K2kr3 w - - 0 1"))

Probes for win/draw/loss-information.

Returns None if the position was not found in any of the tables.

Returns 1 if the side to move is winning, 0 if it is a draw, and -1 if the side to move is losing.

>>> with chess.gaviota.open_tablebases("data/gaviota") as tablebases:
...     tablebases.probe_wdl(chess.Board("4k3/8/B7/8/8/8/4K3 w - 0 1"))

Closes all loaded tables and clears all caches.