Perfect endgame play – with tablebases

4/21/2015 – Can you win an endgame queen vs rook? Don't be so sure – even the best players on the planet can run into problems with it. Especially in rapid chess playoff games, with tens of thousands of dollars at stake. Computers, on the other hand, can handle engames with four, five and six pieces on the board with absolute perfection. And can be installed on your notebook computer.

ChessBase 14 Download ChessBase 14 Download

Everyone uses ChessBase, from the World Champion to the amateur next door. Start your personal success story with ChessBase 14 and enjoy your chess even more!

Along with the ChessBase 14 program you can access the Live Database of 8 million games, and receive three months of free ChesssBase Account Premium membership and all of our online apps! Have a look today!


Perfect endgame play (1)

Endgame databases are a special took used by chess playing programs to increase playing strength and analytical capabilities. They are fully analysed endgames for which the program has perfect knowledge – it knows the status of every single legal position that is possible with a given material configuration.

Positions with the attacking side on the move are circles, the defender-to-move positions are squares

And this, in a nutshell, is how it works: first you define the material you want to analyse, e.g. king and queen vs king and rook. Then you generate every legal position that is possible with the given material. Then you mark all positions in which one side is mated with a zero. Then you mark all positions in which the attacking side can achieve a zero-position in one move with a one. Then you mark all positions in which every legal move of the defending side leads to a position marked one, and mark it two. Then you mark all positions in which the attacker can achieve a position marked two in one move with a three. Etc. And this et cetera can run into the millions and billions.


One of the first endgames that was exhaustively calculated was the four-piece ending queen vs rook. It was done by Ken Thompson back in the early ninteen eighties. He generated every legal position with K+Q vs K+R – 1,900,000 in all – and working backwards from mates created a list in which every position contained information with the distance to mate (the longest was 61 moves).

A program that has access to such an "endgame database" – today the term "tablebase" is more commonly used – plays the endgame with absolute perfection – "as well as god", Thompson once quipped. The four-piece ending queen vs rook was the first important endgame to be solved in this way. And it was surprisingly difficult to play. Many GMs were not able to win it against the perfect defence of the computer, so for example Walter Browne during a tournament in the 1980s, when he lost a $100 bet by not being able to capture the rook against Thompson's database.

Frederic Friedel had a lot of fun with this first endgame database: at one tournament he offered $10 to anyone who could win with the queen. One of the players dragged GM Artur Jussupow to take on the computer – and had to shell out the ten dollars. At one event he had Kasparov and Karpov consulting while trying to overcome the computer – they too failed. And once, when the 14-year-old Peter Leko was staying at the Friedels' house, Frederic challenged him. Peter wasn't able to do it either. BUT: the next morning at breakfast he said he had found the strategy in the night, and proved it by easily winning test positions against the computer. The lad had actually worked it out in his head, while lying in bed in the dark.

Even in practical play sometimes top GMs can have their problems. This is what happened at the FIDE World Championship 2001 in Moscow: in the round five playoffs Peter Svidler reached a Queen vs Rook position against Boris Gelfand. Instead of resigning, as most players might have done, Boris Gelfand simply challenged his opponent to prove that he could win with the queen.

[Event "2001/2002 World Chess Cha"] [Site "Moscow"] [Date "2001.12.07"] [Round "5"] [White "Gelfand, Boris"] [Black "Svidler, Peter"] [Result "1/2-1/2"] [ECO "E05"] [WhiteElo "2714"] [BlackElo "2695"] [PlyCount "258"] [EventDate "2001.??.??"] [WhiteTeam "Israel"] [BlackTeam "Russia"] [WhiteTeamCountry "ISR"] [BlackTeamCountry "RUS"] 1. Nf3 Nf6 2. c4 e6 3. d4 d5 4. g3 Be7 5. Bg2 O-O 6. O-O dxc4 7. Qc2 a6 8. a4 Bd7 9. Qxc4 Bc6 10. Bg5 Bd5 11. Qd3 Be4 12. Qe3 Nbd7 13. Nc3 Bc6 14. Qd3 h6 15. Bxf6 Nxf6 16. e4 b6 17. Rfd1 Bb7 18. d5 Bc5 19. Ne5 exd5 20. Nxd5 Nxd5 21. exd5 Qf6 22. Nd7 Qxf2+ 23. Kh1 Rfd8 24. Rf1 Qe3 25. Qf5 Qe7 26. Nxc5 bxc5 27. Rae1 Qd7 28. Qxd7 Rxd7 29. Rc1 Bxd5 30. Rxc5 Bxg2+ 31. Kxg2 Rd2+ 32. Rf2 Rxf2+ 33. Kxf2 Rb8 34. Rc2 Rb4 35. Ke3 Rxa4 36. Rxc7 Rb4 37. Rc2 a5 38. Kd2 a4 39. Rc8+ Kh7 40. Kc3 Rb3+ 41. Kc2 Rf3 42. Ra8 Rf2+ 43. Kc3 Rxh2 44. Rxa4 Rh3 45. b4 Rxg3+ 46. Kc4 h5 47. Ra1 h4 48. b5 Re3 49. b6 Re8 50. b7 Rb8 51. Rb1 g5 52. Kd5 h3 53. Ke4 h2 54. Kf5 Rxb7 55. Rh1 Rb2 56. Kxg5 Kg7 57. Kg4 Kg6 58. Kg3 Kg5 59. Rf1 f5 60. Kh3 Rf2 61. Ra1 Re2 62. Rh1 Kf4 63. Rf1+ Ke4 64. Kg3 Ke5 65. Ra1 f4+ 66. Kf3 Ra2 67. Rh1 Rb2 68. Kg4 Rf2 69. Kh3 Ke4 70. Re1+ Kd3 71. Ra1 Rd2 72. Ra3+ Kc2 73. Ra2+ Kb1 74. Rxd2 h1=Q+ 75. Kg4 Kc1 76. Rd3 Qe4 77. Rf3 Kd2 78. Rxf4 {[#]This is where the endgame begins. The computer tells us that Black to move can mate in 22 moves. For each move below we give the distance to mate as a number behind the move. Exclamation points are used whenever there is a single move which shortens the distance to mate.} Qg6+ $1 {21} ({Here's how a computer engine equipped with tablebase would play (against perfect defence):} 78... Qg6+ 79. Kf3 Kd3 80. Kf2 Qh6 81. Rf3+ Ke4 82. Kg3 Qg5+ 83. Kf2 Qh4+ 84. Kg2 Qg4+ 85. Rg3 Qe2+ 86. Kg1 Kf4 87. Rh3 Qd2 88. Kf1 Kg4 89. Rh8 Qc1+ 90. Ke2 Qb2+ 91. Kd3 Qxh8 92. Kc4 Qe5 93. Kb4 Kf3 94. Kc4 Ke4 95. Kb3 Qd4 96. Ka3 Kd3 97. Ka2 Kc2 98. Ka3 Qe4 99. Ka2 Qa8#) 79. Kf3 {21} Kd3 $1 {20} 80. Kf2 {20} Qg5 {21} 81. Kf3 {21} Qg1 {24} 82. Rf5 {24} Qe3+ {23} 83. Kg4 {23} Ke4 $1 {22} 84. Rf8 {19} Qg1+ $1 {18} 85. Kh5 $4 {6. Boris Gelfand has put up a flawless defence, but here he allowed a deadly fork, which Peter Svidler did not see!} Qg7 $4 {21} (85... Qc5+ $1 {5} 86. Kg4 Qxf8 {4}) 86. Rf1 {21} Qe5+ {22} 87. Kg4 {22} Qe6+ {21} 88. Kg5 {21} Qg8+ $1 {20} 89. Kh4 {20} Qg6 {19} 90. Kh3 {17} Ke3 {20} (90... Qg5 {16}) 91. Kh4 {20} Qh7+ {23} (91... Qe4+ {19}) 92. Kg3 $2 {16} (92. Kg5 {23}) 92... Qg8+ {15} 93. Kh3 {15} Qg5 {14} 94. Kh2 {14} Ke2 {14} 95. Rg1 {14} Qf4+ {14} 96. Kh3 {14} Qh6+ {13} 97. Kg3 {13} Qe3+ {13} 98. Kh2 {13} Kf2 {18} (98... Qd4 {12}) 99. Rg2+ {18} Kf1 {17} 100. Rg4 {17} Qe5+ {16} 101. Kh3 {16} Kf2 {15} 102. Kh4 {15} Kf3 $2 {21} (102... Qh2+ $1 {14}) 103. Rg6 {21} Qe7+ {20} 104. Kh5 {20} Kf4 $2 {22} (104... Ke4 $1 {19}) 105. Kh6 {13} (105. Rf6+ $1 {22}) 105... Qh4+ {15} 106. Kg7 {15} Kf5 {14} 107. Rh6 {14} Qe7+ {13} 108. Kg8 {13} Kg5 {13} 109. Rh7 {13} Qe8+ {13} 110. Kg7 {13} Qe5+ {14} 111. Kf7 {14} Qd5+ {13} 112. Kg7 {13} Qd6 {14} 113. Kg8 {14} Kg6 {15} 114. Rg7+ {15} Kf6 {14} 115. Rf7+ {14} Ke6 $1 {13} 116. Kg7 {12} Qg3+ {13} 117. Kf8 {13} Qh4 {13} 118. Kg8 {13} Qg5+ {14} 119. Rg7 {14} Qd8+ {14} 120. Kh7 {14} Qh4+ {14} 121. Kg8 {13} Qh5 {14} 122. Ra7 {12} Qg6+ {13} 123. Kh8 {12} Qf6+ {12} 124. Rg7 {11} Qh6+ {15} 125. Kg8 {15} Qh2 {16} 126. Rg6+ {16} Ke7 {15} 127. Rg7+ {15} Ke8 {14 } 128. Rg6 {14} Qh5 {18} 129. Kg7 {15} Ke7 {14 and draw by the 50 move rule} 1/2-1/2

Pathological positions

But what about the positions that remain unmarked when the process of calculating an endgame is completed? Of the 1.9 million positions in the Queen vs Rook endgame there are a certain number that end up blank. Most are "pathological" positions in which the defending side can exchange the rook for the queen, or even capture it or deliver mate. But there are also more subtle positions, like the following:

Black to play and draw

In this position Black simply gives checks on h7, g7 and f7. If the white king moves onto the e-file then ...Re7 will pin the queen and force an exchange. And if the king moves up to h6 to capture the rook after ...Rh7+ then the black king is stalemated. Try out how long it takes your favourite chess engine to work this all out without tablebases. With them it is instantaneous: the database reveals that the above position has no marking and can pick a move – in this case ...Rh7+ that leads to another unmarked position. The position is a draw.

Endgame databases for notebook computers

In the years after the pioneer work with four-piece endings Ken Thompson and others worked out all five-piece endgames, which have between 212 and 335 million positions each. And then came the six-piece endings, which required truly massive computing power to calculate – and plenty of hard disk space to store. Russian programmer Eugene Nalimov created a new format that required eight times less space than the previous versions. And in 2013 Ronald de Man developed the "Syzygy Bases" that were in turn seven times smaller than the Nalimov tablebases. For the first time it was possible (or practical) to provide users six-men tablebases on DVDs.

If you buy one of our chess programs, they will already play a number of four and five-piece endings (e.g. Q vs R or R+P vs R) perfectly. With Endgame Turbo the programs will play all important five and six-piece endings perfectly. They will in fact use the endgame knowledge in the search, so that positions with many more than six pieces that can be traded down to advantageous six or five-piece endings will be handled perfectly as well.

Endgame Turbo 4 contains all five and 27 of the most important six-piece endgames in the Syzygy format, which can be used with top engines like Komodo 8 or Houdini 4. Endgame Turbo 4 consists of four DVDs with the following endgames:

You can order Endgame Turbo 4 in the ChessBase shop here.
Price: €59.90 – €50.34 without VAT (for customers outside the EU) and $54.03 (without VAT).

Expect to read more about five and six-piece endgame databases in a future report.

Discussion and Feedback Join the public discussion or submit your feedback to the editors


Rules for reader comments


Not registered yet? Register

KevinC KevinC 4/21/2015 02:47
It took Houdini only 5 seconds on a 2.5 GHz quad-cord laptop to realize it was a draw.

I do wish that Chessbase (the program itself) would let you turn off tablebase use with a checkbox. I was using CB10, and had to actually clear the file locations, close the program, and then reopen it to test this.