Endgame tablebases

An endgame tablebase is a computerized database that contains precalculated exhaustive analysis of a chess endgame position.
The tablebase contains the game-theoretical value (win, loss, or draw) of each possible move in each possible position, and how many moves it would take to achieve that result with perfect play.

Nalimov tablebases have solved chess for every position with six or fewer pieces (including the two kings). The whole set of tables requires 1153 GB of hard disk space. Some seven-piece positions have been produced as well.

Chess programs

Most of the time, modern chess programs play endgames well, but in some situations they exhibit a glaring weakness, as we will see later.

Most engines can consult tablebases as a kind of oracle to decide whether to exchange down into an endgame covered by the tablebase. A chess engine can for example avoid exchanging down to losing positions (even if they are very deep) or win by converting into an absolutely won endgame.

The tablebases of all endgames with up to six pieces are available for free download. Unfortunately, Nalimov tablebases require more than one terabyte of storage space.

What advantage has FinalGen over chess programs and Nalimov tableblases?

Unlike Nalimov tablebases, FinalGen is able to solve chess positions with 7 or more pieces. All examples presented here include more than 6 pieces on the chessboard (including the kings). Unlike chess programs, FinalGen produces the game-theoretical value (win, loss, or draw) rather than a mere evaluation.

Eiko Bleicher has designed a commercial program called Freezer, which allows users to build new tablebases from existing Nalimov tablebases with a priori information. The program can produce a tablebase for seven-piece positions with blocked pawns. FinalGen generates tablebases without any kind of a priori information.

Example 1: when computers are wrong

Number of pieces: 7. Execution time: 35 minutes.

The machine we used to generate these examples was a standard AMD Athlon 3500+ system with Windows XP installed and an external disk drive.

We also allowed Fritz 11 to analyse this position. Fritz 11, running on a single core gets you more than 1 million positions per second. 35 minutes later, the result was:
d4 -2.47Nd4 -0.79Ne7 -0.79Ke6 -0.79Nh4 -0.71Ng7 -0.71Kd8 0.00Kc8 0.00Ke8 0.00Ke7 0.00Ng3 +11.88Nh6 +12.85Ne3 +15.20Nd6 +15.71

As you can see, Fritz considers d4 to be a winning move, whereas FinalGen found only a draw for this move.
The reason is that Black captures the white pawn in the most direct way by playing d4, but black pawns become weak and the black knight is tied down to the defence of the d-pawn.

It is interesting to notice that Fritz has evaluated some winning moves to be only 0.79 pawns better for Black, which is not definitive. Also notice that Fritz considers all king moves to be a draw.

What are the disadvantages of FinalGen?

Generating tablebases for positions with 8 or more pieces can be a long, time consuming process.
The time required to generate tablebases depends strongly on the number of pieces and the characteristics of the position. For 7-piece positions, the process can take between 30 minutes and 3 hours (with an AMD Athlon 3500+ processor).

FinalGen reaches its maximum efficiency when solving pawn endings. For instance, one hour can be required to solve a position with two kings and 6 or 7 pawns.

Notice that the amount of calculated positions for each endgame with more than 6 pieces grows to astronomical numbers (billions of positions for 7 pieces endgames).
However, when the process is finished, the analysis of all variations can be obtained almost instantaneously. FinalGen stores the evaluations of all positions that can be reached from the initial one by making legal chess moves.

A major limitation of FinalGen
is that it can only manage endgames with up to one minor or major piece per side, and any number of pawns. Consequently, endgames in which there are 3 knights and king versus a king cannot be solved.

FinalGen has been designed to analyse practical chess endings. Normally you would never end up with 3 knights since you would make your promoted pawn a queen. This kind of endgame is probably of interest only to chess problem hobbyists.
Instead, it is more likely that you play an endgame with a rook and two pawns versus a rook and two pawns. In this situation you can use FinalGen to generate the tablebases for the position. The process will take some hours for an 8-piece position (or dozens of hours depending on the characteristics of the position).

Example 2

Number of pieces: 10. Execution time: 1 hour and 42 minutes.

One of the most famous positions solved with the method of corresponding squares is this endgame study composed by N. Grigoriev.

If squares x and y are corresponding squares, it means that if one player moves to x then the other player must move to y in order to hold his position. In some cases they indicate which square the defending king must move to in order to keep the opposing king away. In other cases, a maneuver by one king puts the other player in a situation where he cannot move to the corresponding square, thus the first king is able to penetrate the position. The theory of corresponding squares is more general than opposition, and is more useful in cluttered positions.

FinalGen is particularly efficient for solving this kind of position. The tablebases for this 10-pieces position were generated in 1 hour and 42 minutes.

We also let Fritz 11 do an infinite analysis on this position. After letting the program run for over 1 hour and 40 minutes, Fritz gave the following evaluations:
Kd1 +2.76Kd2 +1.99Kb2 +1.84Kc2 +1.84Kb1 +1.84axb5 +1.61a5 0.00

As you can see, Fritz considers that:
- Kd1 is the best move (which is true).
- Kd1, Kd2, Kb2, Kc2, Kb1 and axb5+ are all winning moves, which is false. Only Kd1 can force a win. The other moves result only in a draw.

In this ending, c5, d5, and g6 are key squares. If the white king can reach any of them, White wins.
If the white king moves to e4, then the black king must move to d6 in order to prevent White from occupying the key square d5. Remark: Moving to c6 allows the white king to reach g6.
With separated key squares, the shortest path connecting them is significant. If the white king moves to d4, then the black king must move to c6, and so on. The corresponding squares are: d4-c6, e4-d6, d3-c7, e3-d7, f3-e7, d2-c8, e2-d8 and f2-e8.

Thus the general formula is as follows: the white king has the opposition when he occupies, on a right hand adjacent file to the file occupied by the black king, a square of opposite colour to that occupied by the latter.

If the white king manages to reach the g6 key square, then Black can react in two ways:

1. Attacking the white pawns on the queenside. In that case, both sides will have single passed pawns racing to promote to a queen. Before occupying g6 White must ensure that he/she will win the resulting queen ending.

2. Moving toward the kingside and occupying e4 when the white king reaches g6. White can avoid zugzwang by playing a5.

The evaluation of a position

Unlike chess programs, FinalGen produces the game-theoretical value (win, loss, or draw) rather than a mere evaluation. The tablebases are generated by retrograde analysis, working backwards from checkmated positions.

Nalimov tables give the number of moves to the end of a game with best play. It is easy to play perfectly by looking up such a table.
In most cases, FinalGen gives a way to win too, but not necessarily the shortest one. For example, Finalgen might predict Win in 12 moves in a case where Nalimov tablebases indicate Win in 10 moves.

There is no notion of perfect play for a game which ends in a tie. Such a game is merely considered equivalent to a game which goes on forever because neither player can force a victory.

Not all positions can be solved by FinalGen. Sometimes, White or Black can force the promotion of a pawn, transposing into a different endgame that FinalGen cannot solve. In that case, the text Unsolved will be displayed. These unsolvable positions represent about 5% of all positions that can be generated.

Other times, after a pawn gets promoted, the position transposes into an endgame that FinalGen can solve. In such situations, the displayed result can be White wins or Black wins without specifying a number of moves. These positions are stored as bitbases which give the game-theoretical value of positions without the number of moves until promotion or mate.

When available, the evaluation of a position can be one of the following:- "White wins. Mate." The black king is checkmated.- "White mates in X." White checkmates in X moves.- "White wins in X." A white pawn can promote in X moves, and White can force a win.- "White wins." White wins, the number of moves is not known.- "White wins or Draw." White can win or draw.- "Draw."- "Black wins or Draw", "Black wins", "Black wins in X", "Black mates in X", "Black wins. Mate". Analogous to the previous ones from black side.

Example 3

This is a study by A. Nimzowitsch. It is often used to illustrate the technique to win in a knight vs bishop endgame with blocked pawns. The "winning" plan is typically to expel the black king from light squares by delivering checks with the knight, thus allowing the white king to penetrate the position.

However, after generating the tablebases, we can see that the position is a draw with perfect play.