Gaviota's Endgame Tablebases

Discussion of chess software programming and technical issues.

Moderator: Ras

bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Gaviota's Endgame Tablebases

Post by bob »

michiguel wrote:
bob wrote:
michiguel wrote:I have my own tablebase generator for my engine Gaviota with all 5 pieces (not compressed). There is implemented some sort of a cache system to reduce access to disk (64Mb but only a fraction is filled in the following position). There is a lot of room for improvement but it seems that is working fine.

Testing with this position (Best move Rxg5!)

[d]8/8/4kpP1/4p1n1/4K3/3P2R1/8/8 w - - 0 1

I had these results. Looks like it is most convenient to probe the tablebases when the depth remaining is more than 2. It does not diminish the node rate and there is a clear benefit. The efficiency of hits of the table base cache is about 80%.

Code: Select all

--------------------------------------
 Probing     Rate      Solution
 depth       knps    ply     time (s)
-------------------------------------
 all         167      8       0.3
 >1          355      9       0.9
 >2          568     10       0.8
 >3          564     11       2.7
 >4          564     12       5.6
 None        614     16     476.3
--------------------------------------
Of course, this is just one position. Is there a good test suite? Is the probing depth what other people are doing? Any opinions on this? Is there a position that is particularly harsh for the hard drive that I can test?

I guess this must have been thoroughly tested with Nalimov's tables. Note that mine are not compressed (at least yet, I am not sure it is worth the trouble for speed purposes).

When the probing depth is > 2 the output Gaviota has is at the end.

The solution is tricky and very instructive 1. Rxg5 fxg5 2. g7 Kf7 3. Kf5! Kg8! 4. Kg4!! Kf7 5. Kxg5 e4! 6. Kh6! exd3 7. Kh7 and white wins.

if 3 ... Kxg7 4. Kxg5 wins easily
if 4. Kxg5 Kxg7 is a draw
if 6. dxe4 Kxg7 is a draw

Without 1. Rxg5 is hard to see a win for white, and it most likely is a draw after the g6 pawn falls (Ke7-Kf8-Kg7).

Code: Select all

         2   1       0.0    +0.23  1.Rxg5 fxg5
         3   1       0.0    +1.73  1.Ke3
         3   1:      0.0    +1.73  1.Ke3
        35   2       0.0    +1.96  1.Ke3 Ke7
        62   2:      0.0    +1.96  1.Ke3 Ke7
       197   3       0.0    +1.82  1.Ke3 Ke7 2.Rg2
       268   3:      0.0    +1.82  1.Ke3 Ke7 2.Rg2
       652   4       0.0    +1.68  1.Ke3 Ke7 2.Rg2 Kf8
       780   4:      0.0    +1.68  1.Ke3 Ke7 2.Rg2 Kf8
      2423   5       0.0    +1.88  1.Ke3 Ke7 2.Rg2 Ke6 3.Rf2
      2759   5:      0.0    +1.88  1.Ke3 Ke7 2.Rg2 Ke6 3.Rf2
      7141   6       0.0    +2.03  1.Ke3 Ke7 2.Rg2 Ke6 3.Rg1 Ke7
      7682   6:      0.0    +2.03  1.Ke3 Ke7 2.Rg2 Ke6 3.Rg1 Ke7
     24661   7       0.0    +1.75  1.Ke3 Ke7 2.Rg4 Kf8 3.d4 exd4+ 4.Rxd4
                                   Ne6
     25387   7:      0.1    +1.75  1.Ke3 Ke7 2.Rg4 Kf8 3.d4 exd4+ 4.Rxd4
                                   Ne6
     33010   8       0.1      :-(  1.Ke3
     34195   8       0.1      :-(  
     73631   8       0.1    +1.01  1.Ke3 Ke7 2.d4 exd4+ 3.Kf4 Kf8 4.Kf5
                                   Kg7 5.Rb3
     74229   8:      0.1    +1.01  1.Ke3 Ke7 2.d4 exd4+ 3.Kf4 Kf8 4.Kf5
                                   Kg7 5.Rb3
    158161   9       0.3    +1.30  1.Ke3 Ke7 2.d4 exd4+ 3.Kf4 Kf8 4.Ra3
                                   Ke7 5.Ra7+ Ke6 6.g7 Nh3+ 7.Ke4
    163879   9:      0.4    +1.30  1.Ke3 Ke7 2.d4 exd4+ 3.Kf4 Kf8 4.Ra3
                                   Ke7 5.Ra7+ Ke6 6.g7 Nh3+ 7.Ke4
    372703  10       0.8    +1.66  1.Ke3 Ke7 2.d4 exd4+ 3.Kf4 Ne6+ 4.Kf5
                                   Ng7+ 5.Ke4 Kd6 6.Rf3 f5+ 7.Kxd4 Ne6+
                                   8.Ke3
    381458  10       0.8      :-)  1.Rxg5
    381912  10       0.8      :-)  1.Rxg5
    382371  10       0.8      :-)  1.Rxg5
    668535  10       1.4      :-)  1.Rxg5
    671883  10       1.4  +Mat_24  1.Rxg5 fxg5 2.g7 Kf7 3.Kf5 Kg8 4.Kg4
                                   Kf7 5.Kxg5 <EMPTY> <=TRANS
    671885  10:      1.4  +Mat_24  1.Rxg5 fxg5 2.g7 Kf7 3.Kf5 Kg8 4.Kg4
                                   Kf7 5.Kxg5 <EMPTY> <=TRANS
    671891  11       1.4  +Mat_24  1.Rxg5 fxg5 2.g7 <=TRANS
    754371  11:      1.5  +Mat_24  1.Rxg5 fxg5 2.g7 <=TRANS
    754377  12       1.5  +Mat_24  1.Rxg5 fxg5 2.g7 <=TRANS
    938202  12:      1.8  +Mat_24  1.Rxg5 fxg5 2.g7 <=TRANS
    938208  13       1.8  +Mat_24  1.Rxg5 fxg5 2.g7 <=TRANS
   1518511  13:      2.8  +Mat_24  1.Rxg5 fxg5 2.g7 <=TRANS
   1518517  14       2.8  +Mat_24  1.Rxg5 fxg5 2.g7 <=TRANS
   3071098  14:      5.3  +Mat_24  1.Rxg5 fxg5 2.g7 <=TRANS
   3071104  15       5.3  +Mat_24  1.Rxg5 fxg5 2.g7 <=TRANS
I am not quite sure I follow. Do you have _all_ 5 piece endings available? If so, why is the hit rate 80%? It should be 100% assuming

I have all 5 piece endings.
For now, in this first experiment, I probed when I had 5 pieces or less (having all 5 piece endings I do not need to specify to probe just after a capture).
In that case you get exactly the same effect, because the probe after a capture that takes you to 5 pieces is the _only_ probes you can do anyway, because you can't search past a capture to 5 pieces anyway. But when you don't have them all, just probing after a capture is way more efficient, since if you probe after a capture and don't get a hit, you will probe at every node after that and you won't get hits there...


What I meant is for 100 times I probe them, 80 times I find the solution is my own implemented cache, and 20 times I have to go to the disk (which might be in its own cache but I do not know).
I start with the cache completely empty, so most of the first probes are not going to hit my cache.

Is this number reasonable?
I have never measured egtb cache hits vs misses myself, so 80% sounds pretty good since there are 7+ gigs of files...


(1) you only probe after a capture or promotion;

(2) you only probe when you have 5 pieces or less.

as far as the probing depth goes, I have to tune this for the hardware I use. My 15K scsi drives are very fast, both seeking and latency delays. On those I can probe deeper in the tree, but I still restrict it to the first N plies of the search where N is the nominal search depth before extensions.
User avatar
michiguel
Posts: 6401
Joined: Thu Mar 09, 2006 8:30 pm
Location: Chicago, Illinois, USA

Re: Gaviota's Endgame Tablebases

Post by michiguel »

Sven Schüle wrote:
Uri Blass wrote:I think that Ke3 also wins
1.Ke3 Ke7 2.Rg4 Kf8 3.d4 so the position is not good test position.
Hi Uri,

maybe you are right stating that White wins also with your line (probably you want to reply to 3...exd4 with 4.Kf4! followed by 5.Kf5 with the idea Rd4-d7). But do you think it is a tablebase win in 24 moves (like 1.Rxg5) or even less? I don't think so since Gaviota would have found it. And even if it were, the position would still remain a good test position for the purpose of checking tablebase code since after 1.Rxg5 you get a 6-men pawn ending that frequently converts into 5-men very quickly.

Perhaps Miguel can tell us whether Gaviota finds a tablebase win in your line.

Sven
Yes, d4 exd4/ Kf4! is a winning plan. Gaviota confirms it

Code: Select all

      2236   6       0.0    +1.89  4.Kf4 Kg7 5.Kf5 d3 6.Rd4 Nf3 7.Rxd3
      3302   6:      0.0    +1.89  4.Kf4 Kg7 5.Kf5 d3 6.Rd4 Nf3 7.Rxd3
      3551   7       0.0      :-)  4.Kf4
      5944   7       0.0    +2.88  4.Kf4 Kg7 5.Kf5 d3 6.Rd4 Nf3 7.Rd7+ Kf8
                                   8.Kxf6 Ke8 9.Rxd3
      9054   7:      0.0    +2.88  4.Kf4 Kg7 5.Kf5 d3 6.Rd4 Nf3 7.Rd7+ Kf8
                                   8.Kxf6 Ke8 9.Rxd3
      9624   8       0.0      :-)  4.Kf4
     41048   8       0.1    +3.39  4.Kf4 Ne6+ 5.Kf5 Nc7 6.Rxd4 Nb5 7.Rd5
                                   Nc7 8.Rd8+ Ke7 9.g7 Kxd8 10.g8=Q+ Ke7
     46359   8:      0.1    +3.39  4.Kf4 Ne6+ 5.Kf5 Nc7 6.Rxd4 Nb5 7.Rd5
                                   Nc7 8.Rd8+ Ke7 9.g7 Kxd8 10.g8=Q+ Ke7
    143686   9       0.3    +3.50  4.Kf4 d3 5.Kf5 d2 6.Rd4 Nf3 7.Rd8+ Ke7
                                   8.g7 Nh4+ 9.Kg4 Ng2 10.g8=Q Ne3+ 11.Kf4
                                   d1=Q 12.Rxd1 Nxd1
    149150   9:      0.3    +3.50  4.Kf4 d3 5.Kf5 d2 6.Rd4 Nf3 7.Rd8+ Ke7
                                   8.g7 Nh4+ 9.Kg4 Ng2 10.g8=Q Ne3+ 11.Kf4
                                   d1=Q 12.Rxd1 Nxd1
    218029  10       0.5      :-)  4.Kf4
    250155  10       0.5      :-(  4.Kf4
    260462  10       0.5      :-(  
    282844  10       0.6      :-)  4.Kf4
    484400  10       1.0    +3.50  4.Kf4 d3 5.Kf5 d2 6.Rd4 Nf3 7.Rd8+ Ke7
                                   8.g7 Nh4+ 9.Kg4 Ng2 10.g8=Q d1=Q+
                                   11.Rxd1 Ne3+ 12.Kf4 Nxd1
    484412  10:      1.0    +3.50  4.Kf4 d3 5.Kf5 d2 6.Rd4 Nf3 7.Rd8+ Ke7
                                   8.g7 Nh4+ 9.Kg4 Ng2 10.g8=Q d1=Q+
                                   11.Rxd1 Ne3+ 12.Kf4 Nxd1
   1342116  11       3.0    +3.36  4.Kf4 d3 5.Kf5 d2 6.Rd4 Nf3 7.Rd8+ Ke7
                                   8.g7 Nh4+ 9.Kg4 Ng2 10.g8=Q d1=Q+
                                   11.Rxd1 Ne3+ 12.Kf4 Nxd1 13.Qd5
   1360877  11:      3.1    +3.36  4.Kf4 d3 5.Kf5 d2 6.Rd4 Nf3 7.Rd8+ Ke7
                                   8.g7 Nh4+ 9.Kg4 Ng2 10.g8=Q d1=Q+
                                   11.Rxd1 Ne3+ 12.Kf4 Nxd1 13.Qd5
   1437281  12       3.3      :-)  4.Kf4
   1510249  12       3.4      :-)  4.Kf4
   3675630  12       8.8      :-)  4.Kf4
   7023359  12      17.6    +8.70  4.Kf4 d3 5.Kf5 d2 6.Rd4 Nf3 7.Rd8+ Ke7
                                   8.g7 Nh4+ 9.Kg4 Ng2 10.g8=Q d1=Q+
                                   11.Rxd1 Ne3+ 12.Kf4 Nc2 13.Qh7+ Ke8
                                   14.Qxc2
   7208048  12:     17.8    +8.70  4.Kf4 d3 5.Kf5 d2 6.Rd4 Nf3 7.Rd8+ Ke7
                                   8.g7 Nh4+ 9.Kg4 Ng2 10.g8=Q d1=Q+
                                   11.Rxd1 Ne3+ 12.Kf4 Nc2 13.Qh7+ Ke8
                                   14.Qxc2
   7455898  13      18.5      :-)  4.Kf4
  33399297  13      98.9  +Mat_25  4.Kf4 d3 5.Kf5 d2 6.Rd4 Nf3 7.Rd8+ Ke7
                                   8.g7 Nh4+ 9.Kg4 Kxd8 10.g8=Q+ Ke7
                                   11.Qd5 Ng6 12.Qxd2 <=TABLE
  33814370  13:     99.4  +Mat_25  4.Kf4 d3 5.Kf5 d2 6.Rd4 Nf3 7.Rd8+ Ke7
                                   8.g7 Nh4+ 9.Kg4 Kxd8 10.g8=Q+ Ke7
                                   11.Qd5 Ng6 12.Qxd2 <=TABLE
 217978213  14     554.6  +Mat_21  4.Kf4 Ne6+ 5.Kf5 Ng7+ 6.Kxf6 Ne8+ 7.Kf5
                                   Ng7+ 8.Ke5 d3 9.Rd4 Ne8 10.Rxd3 <=TABLE
 220116757  14:    558.5  +Mat_21  4.Kf4 Ne6+ 5.Kf5 Ng7+ 6.Kxf6 Ne8+ 7.Kf5
                                   Ng7+ 8.Ke5 d3 9.Rd4 Ne8 10.Rxd3 <=TABLE
Mate in 21 from here is Mate in 24 from the beginning (same as Rxg5).

If black does not take exd4 and plays Kg7:

Code: Select all

    177132   9:      0.2    +2.96  4.dxe5 Kxg6 5.e6 Kg7 6.Kf4 Kf8 7.Kf5
                                   Ke7 8.Rb4 Nh3 9.Rb7+ Kd8 10.e7+ Ke8
                                   11.Kxf6
    180803  10       0.2    +2.96  4.dxe5 Kxg6 5.e6 Kg7 6.Kf4 Kf8 7.Kf5
                                   Ke7 8.Rb4 Nh3 9.Rb7+ Kd8 10.e7+ Ke8
                                   11.Kxf6
    489921  10:      0.7    +2.96  4.dxe5 Kxg6 5.e6 Kg7 6.Kf4 Kf8 7.Kf5
                                   Ke7 8.Rb4 Nh3 9.Rb7+ Kd8 10.e7+ Ke8
                                   11.Kxf6
    497126  11       0.7    +3.15  4.dxe5 Kxg6 5.e6 Kg7 6.Kf4 Kf8 7.Kf5
                                   Ke7 8.Rb4 Nh3 9.Rb7+ Kd8 10.e7+ Ke8
                                   11.Kxf6 Nf4
   1231561  11:      1.5    +3.15  4.dxe5 Kxg6 5.e6 Kg7 6.Kf4 Kf8 7.Kf5
                                   Ke7 8.Rb4 Nh3 9.Rb7+ Kd8 10.e7+ Ke8
                                   11.Kxf6 Nf4
   1238583  12       1.5    +3.15  4.dxe5 Kxg6 5.e6 Kg7 6.Kf4 Kf8 7.Kf5
                                   Ke7 8.Rb4 Nh3 9.Rb7+ Kd8 10.e7+ Ke8
                                   11.Kxf6 Nf4
   2387409  12:      2.7    +3.15  4.dxe5 Kxg6 5.e6 Kg7 6.Kf4 Kf8 7.Kf5
                                   Ke7 8.Rb4 Nh3 9.Rb7+ Kd8 10.e7+ Ke8
                                   11.Kxf6 Nf4
   2391330  13       2.7    +3.15  4.dxe5 Kxg6 5.e6 Kg7 6.Kf4 Kf8 7.Kf5
                                   Ke7 8.Rb4 Nh3 9.Rb7+ Kd8 10.e7+ Ke8
                                   11.Kxf6 Nf4
   5524620  13:      7.1    +3.15  4.dxe5 Kxg6 5.e6 Kg7 6.Kf4 Kf8 7.Kf5
                                   Ke7 8.Rb4 Nh3 9.Rb7+ Kd8 10.e7+ Ke8
                                   11.Kxf6 Nf4
   6483597  14      10.5    +3.15  4.dxe5 Kxg6 5.e6 Kg7 6.Kf4 Kf8 7.Kf5
                                   Ke7 8.Rb4 Nh3 9.Rb7+ Kd8 10.e7+ Ke8
                                   11.Kxf6 Nf4
  22603834  14:     38.5    +3.15  4.dxe5 Kxg6 5.e6 Kg7 6.Kf4 Kf8 7.Kf5
                                   Ke7 8.Rb4 Nh3 9.Rb7+ Kd8 10.e7+ Ke8
                                   11.Kxf6 Nf4
  26777218  15      55.2      :-)  4.dxe5
  29228314  15      63.1      :-)  4.dxe5
  40510405  15      96.6      :-)  4.dxe5
  59887583  15     152.0      :-)  4.dxe5
  62991715  15     161.1  +Mat_21  4.dxe5 Kxg6 5.e6 Kg7 6.Kf4 Kf8 7.Kf5
                                   Ke7 8.Rb4 Nxe6 <=TABLE
 115125445  15:    252.3  +Mat_21  4.dxe5 Kxg6 5.e6 Kg7 6.Kf4 Kf8 7.Kf5
                                   Ke7 8.Rb4 Nxe6 <=TABLE
 115562248  16     253.5  +Mat_21  4.dxe5 Kxg6 5.e6 Kg7 6.Kf4 Kf8 7.Kf5
                                   Ke7 8.Rb4 Nxe6 <=TABLE

Still the same! Mate in 21, which is Mate in 24 from the beginning.

Miguel