5.8: Endgame Tablebases

A Tablebase is a special type of database which contains perfect information about the result (win to White, win to Black or draw) for every possible legal chess position with a particular set of material. For example, the KQKR contains information for every legal King and Queen versus King and Rook position.

Because the amount of storage goes up exponentially with each extra piece, tablebases are currently limited to 6-men endgames (that is positions with six or fewer pieces or pawns on the board including the kings) and most people only use up to 5-men tablebses since the 6-men files are huge. The approximate size of the tablebases are:

Tablebase formats

The most common tablebase format in current use by chess programs is called the Nalimov format, after its creator Eugene Nalimov. Nalimov tablebases are very compact but fast to access. They contain distance-to-mate information for each position. ChessDB can use all Nalimov tablebases up to five men, such as KRPKR (King, Rook and Pawn versus King and Rook) for example. It can not currently use 6-piece ones, but this might change - it depends on how much work would be needed to add support for 6-piece tablebases.

Nalimov tablebase format files have the extension ".emd". Actually they will end with the suffix "nbw.emd" for White-to-move tablebases, and "nbb.emd" for Black-to-move tablebases. It pays to have both the White to move and Black to move tablebase for a particular material constellation (e.g. "krpkr.nbw.emd" and "krpkr.nbb.emd") for complete information whichever side is to move.

You may find a Nalimov tablebase file with the suffix ".nbw" or ".nbb" with no ".emd". This is an uncompressed tablebase, which is usually huge compared to its compressed (.emd) equivalent. It is far better to get the compressed tablebases, since they are much smaller and just as fast to access.

Obtaining Tablebases

Nalimov tablebases are available for downloading at the Crafty FTP site, in the directory ftp://ftp.cis.uab.edu/pub/hyatt/TB/3-4-5/ It's also possible to buy them from Chessbase or you can generate them yourself, but it is very CPU intensive task, requiring losts of RAM.

Setting up Tablabases in ChessDB

Once you have a directory (or 2 or 3) of tablebase files, you need to inform ChessDB which directories to look in for tablebases when the application starts. To do this, select Tablebase Directory... from the Options menu in the ChessDB main window.

Select tablebase directories

For each tablebase folder you have, select a Nalimov (.emd) file in the folder. It doesn't matter which file you select; all tablebases in that folder will be loaded each time you start ChessDB.

It may be confusing to select a file instead of a folder, but the reason is so you can be sure you are selecting a folder which actually contains tablebase files.

Tablebase information in the game window

Chessboad showing black mates in 16

The game board above shows some tablebase information, although generally not very much. The game board shows a game played on the Internet Chess Club (ICC) between myself (handle g8wrb) and Jake-1964. Since there are only 5-pieces on the board, and the 5-piece table bases were loaded, ChessDB can indicate the result with perfect play on both sides. The board shows white can win is 16 moves, but does not say how.

The Tablebase window

Endgame Tablebase Window

You can get even more tablebase information about the current position by opening the Tablebase window ([Windows] menu, shortcut: Ctrl+Shift+=). This window shows the result with perfect play of all legal moves from the current position.

The Tablebase Wwindow has two main parts. The summary frame (on the left) shows which tablebases ChessDB found on your computer and a summary for each tablebase. The results frame (on the right) shows optimal results for all moves from the current position displayed in the main window.

The summary frame

The top part of the summary frame lets you select a particular tablebase. Those you have available are shown in blue and unavailable tablebases are shown in gray, but you can select any tablebase. The lower part of the summary frame shows summary information for the selected tablebase. (Not all tablebases have a summary recorded in ChessDB yet.)

The summary includes the frequency (how many games per million reach a position with this material, computed from a database of more than 600,000 master-level games), a longest mate for either side, and the number of mutual (or "reciprocal") zugzwangs. A mutual zugwang is a position where white to move draws and black to move loses, or where white to move loses and black to move draws, or where whoever moves loses.

For some tablebases with mutual zugzwangs, the summary also includes a list of all of the zugwang positions or a selection of them. A full list for every tablebase is not feasible since some tablebases have thousands of mutual zugzwangs.

You can set up a random position from the selected tablebase by pressing the Random button.

The results frame

The results frame is updated whenever the chessboard in the main window changes. The first line shows how many moves win (+), draw (=), lose (-), or have an unknown result (?). The rest of the frame gives a more detailed list of results, ranking them from shortest to longest mates, then draws, then longest to shortest losses. All distances are to checkmate.

The results board

In a tablebase position, it is often useful what the tablebase results would be if all the pieces in the current position were on their current squares but one particular piece was moved somewhere else. For example, you may want to determine how close a king has to be to a passed pawn to win or draw a particular position. In endgame books this information is often called the winning zone or drawing zone of a piece in a position.

You can find this information in ChessDB by pressing the button with an image of a chessboard, to show the results board in the tablebase window. When you press the left mouse button on any piece in this board, a symbol is drawn in each empty square showing what the tablebase result would be (with the same side to move as the current main window position) if the selected piece was on that square.

There are five different symbols a square can have: a white # means White wins; a black # means Black wins; a blue = means the position is drawn; a red X means the position is illegal (because the kings are adjacent or the side to move is giving check); and a red ? means the result is unknown because the necessary tablebase file is not available.

If you would like to contribute to the tutorial or see anything that should be updated, corrected or improved, please contact David Kirkby. But please note David only speaks English.


Valid HTML 4.01 Valid CSS!
Website administered by Dr. David Kirkby
This page was last modified: September 16, 2007. 11:41:41 am GMT