A question about syzygy

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

acconcio
Posts: 22
Joined: Tue Feb 04, 2014 9:52 pm
Location: Italy Milan

A question about syzygy

Post by acconcio »

I created all the positions of syzygy with 5 men, using the script generation tablebases. It may happen that some positions with 5 pieces are not found? Or if that happens, it is an error due to corrupt database? It 'safer download the database from the internet or is it better to create it with programs written by the author of syzygy?
When stockfish see part 145 database, is that correct?

Code: Select all

Stockfish 240214 64 SSE4.2 by Tord Romstad, Marco Costalba and Joona Kiiski
info string Found 145 tablebases
.
ciao and thanks
syzygy
Posts: 5563
Joined: Tue Feb 28, 2012 11:56 pm

Re: A question about syzygy

Post by syzygy »

acconcio wrote:When stockfish see part 145 database, is that correct?
That is correct.

You probably mean that SF starts to search as normal on 5 piece positions. This is by design. See https://github.com/syzygy1/Stockfish under "What to expect" (not entirely up to date anymore, but the point remains: it is normal that SF does a search, it will however report large positive or negative scores if it is winning or losing).
acconcio
Posts: 22
Joined: Tue Feb 04, 2014 9:52 pm
Location: Italy Milan

Re: A question about syzygy

Post by acconcio »

syzygy wrote:
acconcio wrote:When stockfish see part 145 database, is that correct?
That is correct.

You probably mean that SF starts to search as normal on 5 piece positions. This is by design. See https://github.com/syzygy1/Stockfish under "What to expect" (not entirely up to date anymore, but the point remains: it is normal that SF does a search, it will however report large positive or negative scores if it is winning or losing).
for example this is the code from search:

Code: Select all

if (   !RootNode
        && depth >= TBProbeDepth
        && pos.count<ALL_PIECES>&#40;WHITE&#41; + pos.count<ALL_PIECES>&#40;BLACK&#41; <= TBCardinality
        && pos.rule50_count&#40;) == 0&#41;
    &#123;
        int found, v = Tablebases&#58;&#58;probe_wdl&#40;pos, &found&#41;;

        if &#40;found&#41;
        &#123;
            TBHits++;

            if &#40;TB50MoveRule&#41; &#123;
                value = v < -1 ? -VALUE_MATE + MAX_PLY + ss->ply
                      &#58; v >  1 ?  VALUE_MATE - MAX_PLY - ss->ply
                      &#58; VALUE_DRAW + 2 * v;
            &#125;
            else
            &#123;
                value = v < 0 ? -VALUE_MATE + MAX_PLY + ss->ply
                      &#58; v > 0 ?  VALUE_MATE - MAX_PLY - ss->ply
                      &#58; VALUE_DRAW;
            &#125;

            TT.store&#40;posKey, value_to_tt&#40;value, ss->ply&#41;, BOUND_EXACT,
                     depth + 6 * ONE_PLY, MOVE_NONE, VALUE_NONE&#41;;

            return value;
        &#125;
    &#125;
If there are 145 database (5men complete) and database is not corrupted and generated correctly after

Code: Select all

v = Tablebases&#58;&#58;probe_wdl&#40;pos, &found&#41;;
is possible that syzygy returns found=false?

Thanks you very much & ciao.

P.S.
If i can ask:

Code: Select all

                value = v < -1 ? -VALUE_MATE + MAX_PLY + ss->ply
                      &#58; v >  1 ?  VALUE_MATE - MAX_PLY - ss->ply
<-1 or >1 is to report win/v>1 loss/v<-1?
syzygy
Posts: 5563
Joined: Tue Feb 28, 2012 11:56 pm

Re: A question about syzygy

Post by syzygy »

acconcio wrote:If there are 145 database (5men complete) and database is not corrupted and generated correctly after

Code: Select all

v = Tablebases&#58;&#58;probe_wdl&#40;pos, &found&#41;;
is possible that syzygy returns found=false?
On a position with 5 pieces, found should be true. If files are corrupted you are more likely to get a crash than found=false. The only integrity check that the probing code does is comparing the first 4 bytes of a file to a magic value.

It is not impossible that the latest SF version has problems due to changes within SF that mess up the calculation of the material key. I thought the most recent version correctly tracked these changes, but if you get found=false, then that is probably the problem. Make sure you have the latest version or sources. You could also try a version from 2 weeks ago or earlier.
P.S.
If i can ask:

Code: Select all

                value = v < -1 ? -VALUE_MATE + MAX_PLY + ss->ply
                      &#58; v >  1 ?  VALUE_MATE - MAX_PLY - ss->ply
<-1 or >1 is to report win/v>1 loss/v<-1?
The possible return values from probe_wdl() are -2 / -1 / 0 / 1 / 2, which stand for loss / loss but 50-move draw / draw / win but 50-move draw / win, all from the point of view of the side to move.
acconcio
Posts: 22
Joined: Tue Feb 04, 2014 9:52 pm
Location: Italy Milan

Re: A question about syzygy

Post by acconcio »

thanks for the reply, it is a very interesting topic.
ciao e grazie!
syzygy
Posts: 5563
Joined: Tue Feb 28, 2012 11:56 pm

Re: A question about syzygy

Post by syzygy »

syzygy wrote:The possible return values from probe_wdl() are -2 / -1 / 0 / 1 / 2, which stand for loss / loss but 50-move draw / draw / win but 50-move draw / win, all from the point of view of the side to move.
To be a bit more precise: from the point of view of the side to move and assuming the 50-move counter has just been reset. Typically, probe_wdl() will be called after a capture (into a position with 5 or 6 pieces), so that the 50-move counter indeed just has been reset.