Tablebase suggestion

Discussion of anything and everything relating to chess playing software and machines.

Moderator: Ras

syzygy
Posts: 6059
Joined: Tue Feb 28, 2012 11:56 pm

Re: Tablebase suggestion

Post by syzygy »

syzygy wrote: ↑Sun May 24, 2026 3:42 pm
Rein Halbersma wrote: ↑Sat May 23, 2026 11:40 pm
syzygy wrote: ↑Sat May 23, 2026 4:14 pm For regular chess we know that we have two kings with multiplicity 1. We can start by placing them in the usual way. This also avoids a lot of illegal positions.
Then in 441 out of 462 cases we're already done: no symmetries left, and the remaining pieces can be placed group by group using combinadics.

In the remaining 21 cases, both kings are on the main diagonal. There is now exactly one diagonal symmetry left.
There are 28 orbits of size 2, 6 orbits of size 1.
ChatGPT happily ploughed through all this. I let it generate prefix tables for 22 classes: 1 with the trivial stabilizer (both kings uniquely fix the position) and 21 different tables (1 for each king pair, with white king on a1, b2, c3 or d4). Remaining pieces are still placed orbit by orbit, but the kings positions are remembered, i.e. effectively, the state for the recursion is now (kings positions, #orbits, #material, stabilizer)
Different tables for the 21 king placements on the diagonal should not be needed. Perhaps you need to renumber the orbits on the diagonal so that the empty ones are 0-5 and the king ones are 6,7, for example. This reordering commutes with the reflection.
My perfect ranking function is now fully integrated into my new generator:
https://github.com/syzygy1/tb8gen/blob/ ... #L485-L723

The precomputed table has 2160 entries of 56 bytes, so about 120kb, but only 201 are actually valid (for up to 8 pieces including kings):

Code: Select all

// Per transition, one case per number of 2-orbits filled.
struct TransitionCase {
  uint8_t d;
  uint8_t rem;
  uint64_t diag_tail;
  uint64_t diag_block;
  uint64_t broken_tail;
  uint64_t per_full_block;
  uint64_t block;
  uint64_t prefix;
};

// There are 201 valid cases.
static struct TransitionCase transition_cases[45][12][4];
45 is the number of pairs (partition_of_<= 6 , member m of the partition). This is the material still to be placed (not including the kings). with m being the size of the group of identical pieces to be placed next.

12 refers to the number of pairs (p, s) with p, s >= 0 and 2 * p + s <= 5.
Here p is the number of 2-orbits (pairs of squares symmetric in the main diagonal) and s is the number of 1-orbits (squares on the main diagonal) that are fully occupied by the non-king pieces already placed. (In the code it is the inverse: empty 2-orbits, empty 1-orbits.)

4 is the possible number of 2-orbits d being occupied by group of pieces being placed next. So 0 <= d <= 3.

There are additional restrictions such as 2 * p + s + m <= 5 and 2 * d <= m, resulting in a total of 201 cases as mentioned.
I should probably pad the TransitionCase struct to 64 bytes and align the table on a cache line, so the table can only ever occupy 201 lines in the cache. (And then I can as well unfold p and s and make the array [45][3][6][4].)

Initially I only wanted to use the perfect ranking function for the final compressed format, but I decided to use it also during generation. Mainly because the generator can now directly report the final "clean" statistics as it calculates the wins and losses for each ply.

I think it should be possible to iterate through all unranked positions incrementally, but I haven't yet studied the code that ChatGPT generated for this :).
User avatar
Ajedrecista
Posts: 2292
Joined: Wed Jul 13, 2011 9:04 pm
Location: Madrid, Spain.

Re: Tablebase suggestion.

Post by Ajedrecista »

Hello:
syzygy wrote: ↑Sun Jan 18, 2026 2:29 am[...]

The 8-men positions with 1 opposing pair have been computed by Marc Bourzutschky (DTC metric) and are accessible here:
https://op1-tables.info/

8-men with 1 opposing pair only needs 82.5 GB of RAM with 1 byte per position if you split it up in pawn slices with the pair fixed, so it does not need a big machine.
9-men with 2 opposing pairs should only need 1.2 GB of RAM with 1 byte per position.
[...]
Any news about 9op2?

------------

In the meanwhile, I composed other position that can use 8op1 at some point:

[d]8/8/5pPp/1Pbk1Pr1/5KP1/4pNP1/8/8 w - - 0 1

This one is easy for SF 19 with the full set of 3, 4 and 5-man Syzygy EGTB, but I was amazed to the high number of only moves, some of them a bit counterintuitive for me at first glance. Here is the PGN with some sidelines ['!' for only moves that preserve the current result (win or draw) unless all legal moves preserve it; and '?' for moves that throw the current result (win → draw, win → lose or draw → lose)]:

[pgn][Event ""]
[Site ""]
[Round ""]
[Date ""]
[SetUp "1"]
[FEN "8/8/5pPp/1Pbk1Pr1/5KP1/4pNP1/8/8 w - - 0 1"]
[PlyCount "27"]
[Result "1/2-1/2"]

1.Nxg5! (1.g7? Rxg7 0-1) fxg5+! (1...hxg5+? 2.Kf3 Bf8 3.Kxe3! Kc5 4.Ke4! (4.b6? Kxb6! 5.Kd4 Kc6 1/2-1/2) 4...Kxb5 5.Kd5! 1-0) 2.Kf3 Bd4! 3.b6! (3.f6? (3.Ke2? Kc5! 4.f6 (4.Kd3 Bf6 (4...Bg7? 5.Kxe3! Kxb5! 6.f6 Bxf6! 7.Ke4! Kc5 8.Kf5! Bh8! ({(And so on, as in the mainline)}) 1/2-1/2) 5.Kxe3 Kxb5! 6.Ke4 Kc4 0-1) Bxf6! 5.Kxe3 Kd6 (5...Kxb5? 6.Ke4! 1/2-1/2) 0-1) 3...Ke6 0-1) 3...Kc6! (3...Bxb6? 4.g7 1-0) 4.f6! (4.Ke4? e2 0-1) 4...Bxf6 (4...e2 5.Kxe2! Bxf6! 6.Ke3 Kxb6 7.Ke4! Kc5! 8.Kf5! Bh8! ({(And so on, as in the mainline)}) 1/2-1/2) 5.Kxe3! Kxb6! 6.Ke4! Kc5! 7.Kf5! Bh8! (7...Bg7? 8.Ke6! Kd4 9.Kf7! Bh8 10.g7! Bxg7 11.Kxg7! Ke3 12.Kxh6! Kf3 13.Kxg5 Kxg3 14.Kf5 1-0) 8.Ke6! Kd4! 9.Kf7! Ke3 10.g7! Bxg7! 11.Kxg7! Kf3! 12.Kxh6! Kxg4! (12...Kxg3? 13.Kxg5! 1-0) 13.Kg6! Kxg3 14.Kxg5! 1/2-1/2[/pgn]
  • After the initial trade, the imbalance is PP v B.
  • 1.- N×R is the only drawing move. If there had been a knight instead of a rook, 1.- N×N would still had been the only drawing move because the greedy move 1.- g7 is met by 1.- ..., Nh3#, such an unusual checkmate setup.
  • 1.- ..., hxg5+ loses because does not unlock the d4-h8 diagonal for the bishop and allows the unstoppable 3.- g7 unless 2.- ..., Bf8, that loses the e-pawn and the game, as shown in a sideline. This time, leading pawns to the centre is wrong.
  • Order matters with 3.- b6 and 4.- f6. Please look at all subtleties in all the given sidelines.
  • Tempo matters with a direct 7.- ..., Bh8, another ugly move. 7.- ..., Bg7 allows white a faster attack to the bishop and black must waste valuable moves to place better its king.
------------

My modest compositions usually admit variants around a same idea, but sometimes little changes can turn the wave wildly. What about adding other doubled pawn on g2 for white? It is just a mere doubled pawn, not advanced and might not even advance in case for taking advantage to create a zugzwang. Draw again... really?

[d]8/8/5pPp/1Pbk1Pr1/5KP1/4pNP1/6P1/8 w - - 0 1

[pgn][Event ""]
[Site ""]
[Round ""]
[Date ""]
[SetUp "1"]
[FEN "8/8/5pPp/1Pbk1Pr1/5KP1/4pNP1/6P1/8 w - - 0 1"]
[PlyCount "25"]
[Result "1-0"]

1.Nxg5! fxg5+ 2.Kf3 Bd4 3.b6! Kc6 4.f6! Bxf6 5.Kxe3! Kxb6 6.Ke4! Kc5 7.Kf5! Bh8 8.Ke6! Kd4 9.Kf7! Ke3 10.g7! Bxg7 11.Kxg7! Kf2 12.Kxh6! (12.Kg6? Kxg3! (12...Kxg2? 13.Kxh6! Kxg3 14.Kxg5 1-0) 13.Kxh6 Kxg4 (13...Kh4 (13...Kf4? 14.Kh5! 1-0) 1/2-1/2) 1/2-1/2) 12...Kxg3 13.Kxg5 1-0[/pgn]
  • After the initial trade, the imbalance is PPP v B.
  • The key is that the not-so-innocent g2 pawn defends the f3 square, forcing the black king to move away from the most advanced white g4-pawn.
  • The blunder of 12.- Kg6 misses the only move to win, as shown in a sideline. Then, please watch the only move that draws for black: order of captures matters.
Regards from Spain.

Ajedrecista.
Jouni
Posts: 3982
Joined: Wed Mar 08, 2006 8:15 pm
Full name: Jouni Uski

Re: Tablebase suggestion

Post by Jouni »

Tablebases needs also testing. For pawnocchio they gave -50 elo :!:
Jouni
User avatar
Ajedrecista
Posts: 2292
Joined: Wed Jul 13, 2011 9:04 pm
Location: Madrid, Spain.

Re: Tablebase suggestion.

Post by Ajedrecista »

Hello:

As there had been several posts in this thread about draughts databases, there are recent news in the field of huge tablebases: KingsRow's programmer publicly announced today that he has built 12-man EGDB for English checkers. You would realize how such big step is with the previous 10-man EGDB when compared along the 'search space complexity' metric (page 7 of this paper).

There are more details in an entry of his web: 1.7 years to build and self-verify using a 16-core Xeon workstation with 192 GB of ECC RAM, redisign of indexing format to achieve similar initialization time than 10-man EGDB...
  • Summary for the WDL databases (called WLD by him): 2.88 TB of disk space when unzipped (29 times larger than 10-man EGDB), at least 10 GB of cache memory allocation...
  • Summary for the MTC database (moves to conversion, a distance-to-conversion database that guides the engine to play the shortest path to the next non-reversible move): 872 GB of disk space when unzipped, only 230 MB of cache memory allocation, 3 seconds of initialization on a SSD...
There is even a huge list of the longest MTC positions in each database subdivision.

I hope that this info might inspire the people here who are pondering how to build other tablebases.

Ajedrecista.
Dann Corbit
Posts: 12898
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Tablebase suggestion

Post by Dann Corbit »

Jouni wrote: ↑Sat Sep 26, 2026 10:23 pm Tablebases needs also testing. For pawnocchio they gave -50 elo :!:
I guess that the testing results will be skewed one way or another depending on the disk type.
I have an array of PCIe-4 gumstick SSDs and regularly get 500MB/Second.
There are raid setups that get terrific throughput, even with ordinary disks.
Using a single platter type hard drive will give the worst results, I am sure.
I also suspect that the bitbase versions will outperform the full lookups.
That's how testing has gone for me.
Edit: I also have 256GB physical RAM so I will get a lot of cache benefit.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
Jouni
Posts: 3982
Joined: Wed Mar 08, 2006 8:15 pm
Full name: Jouni Uski

Re: Tablebase suggestion

Post by Jouni »

Latest dev has same bug:

Code: Select all

Score of pawnocchio-TB vs Pawnocchio3.0-dev: 37 - 62 - 101 [0.438]
...      pawnocchio-TB playing White: 11 - 33 - 56  [0.390] 100
...      pawnocchio-TB playing Black: 26 - 29 - 45  [0.485] 100
...      White vs Black: 40 - 59 - 101  [0.453] 200
Elo difference: -43.7 +/- 33.9, LOS: 0.6 %, DrawRatio: 50.5 %
200 of 200 games finished.
Note, that ALL other engines I have tested gained +5 to + 25 in same test.
Jouni