question about syzygy probing

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

elcabesa
Posts: 855
Joined: Sun May 23, 2010 1:32 pm

question about syzygy probing

Post by elcabesa »

I started reading some code about syzygy teblebase probing and i don't uderstand why a position is probed ony if 50 rule moves is equal to zero.

I think that position with 50 move rules is equal to 0 are very few. isn't probe code albe to asses position with 50moveCounter >0 ?
syzygy
Posts: 5566
Joined: Tue Feb 28, 2012 11:56 pm

Re: question about syzygy probing

Post by syzygy »

elcabesa wrote:I started reading some code about syzygy teblebase probing and i don't uderstand why a position is probed ony if 50 rule moves is equal to zero.

I think that position with 50 move rules is equal to 0 are very few. isn't probe code albe to asses position with 50moveCounter >0 ?

Code: Select all

    if (!RootNode && popcount<Full>&#40;pos.pieces&#40;)) <= use_tb
                  && pos.rule50_count&#40;) == 0&#41; &#123;
      // call to probe_wdl&#40;) and return immediately
    &#125;
If we have 6 piece tables, we should only probe positions with 6 pieces or less. So we check this (popcount<Full>(pos.pieces()) <= use_tb).

If we are in a position with use_tb pieces or less, then almost always the parent position will have had use_tb + 1 pieces (or we would have probed there and returned immediately!). So the last move was a capture and pos.rule50_count() == 0.

So it is very normal to probe only if rule50_count() == 0. The question should be: why check for this condition at all? It should always be true anyway.

The answer is that the check is there to help in the situation that the root position is already in the TBs, but DTZ tables are not available. In that case the engine searches for a winning zeroing move (capture or pawn move) in order to ensure progress. And the test for a zeroing move is pos.rule50_count() == 0.

If the position on the board is in the WDL TBs but DTZ TBs are not available, it would not make sense to probe WDL TBs everywhere in the tree and return immediately. The effect would be that the search only does a single ply and does not learn how to make real progress.

What wat one could do instead, if the root position is in the WDL TBs and winning and DTZ is not available, is call probe_wdl() everywhere but not return immediately but only use the result to filter out non-winning moves. But I did not think it worth the effort to deal too extensively with the case that DTZ is not available.

There is also the detail that probe_wdl() only returns reliable 50-move draw information for positions with rule50_count == 0.
elcabesa
Posts: 855
Joined: Sun May 23, 2010 1:32 pm

Re: question about syzygy probing

Post by elcabesa »

ok understood. it's my first time checking the TB code and I was surprised to find that the TB was checked in less that 1% nodes of my actual search.
elcabesa
Posts: 855
Joined: Sun May 23, 2010 1:32 pm

Re: question about syzygy probing

Post by elcabesa »

so if I had understood: in a knb vs k condition the ab_search get no help from the probe_wdl to choose the best move. it only get the info that losing a piece would change the positioni n a draw one.
on the other side it receive, in te same condition, an help in the root node to choose the correct move.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: question about syzygy probing

Post by bob »

elcabesa wrote:so if I had understood: in a knb vs k condition the ab_search get no help from the probe_wdl to choose the best move. it only get the info that losing a piece would change the positioni n a draw one.
on the other side it receive, in te same condition, an help in the root node to choose the correct move.
This is a subtle issue, but basically WDL tells you that and only that the position in question is won, drawn or lost, assuming you just made a capture or promotion to reach this position. Otherwise it could not possibly handle the 50 move rule correctly as the file was built assuming that when you reach it via a capture or promotion you just reset the 50 move counter. If you probe on the capture or promotion, how could you probe anywhere else later since the search should have terminated at the point where you transitioned into this specific ending?

You still have to handle the root separately using DTZ50 in order to win the winnable positions, since the WDL doesn't tell you how to make progress, only that you are winning, etc. Unfortunately, that will fail if you probe them the next move because now the 50 move counter is at 1, but the data expects it to be zero, and you could choose a move that is winning in exactly 50 moves from the current position, but which would be a draw since at that point the 50 move counter would be 51. With DTZ50, you have to make a move where the distance to zero from the file + the current 50 move rule counter is <= 50... WDL lacks that distance to zero information.

I first added DTM around 1995, using Steven Edward's DTM table bases. The recurring question was always "why do you only probe on a capture?" Nowadays the answer is pretty obvious. If you get a hit on a capture, you will never probe again below that node because you terminate the search at that point with perfect information. If you don't get a hit when you transition to this combination of material, how could you get a hit later in the search with the same material combination?

There are other issues dealing with pawn promotion cases that can also cause interesting issues.
syzygy
Posts: 5566
Joined: Tue Feb 28, 2012 11:56 pm

Re: question about syzygy probing

Post by syzygy »

elcabesa wrote:so if I had understood: in a knb vs k condition the ab_search get no help from the probe_wdl to choose the best move. it only get the info that losing a piece would change the positioni n a draw one.
Yes, probe_wdl() returns one of -2, -1, 0, 1, 2, meaning a loss, cursed loss (i.e. draw by 50-move rule), draw, cursed win (i.e. draw by 50-move rule), real win.
on the other side it receive, in te same condition, an help in the root node to choose the correct move.
At the root, the engine is supposed to use probe_dtz() to figure out which move makes progress. For a winning position, this gives the distance to the nearest winning zeroing move (capture or pawn move or mate). By trying out all root moves, the engine can find out which root move gets one ply closer.

In case of KBNvK, a winning zeroing move will of course be a mate.

In other positions, getting to a zeroing move guarantees progress: there are only so many captures and pawn moves that you can make. Eventually you run out of them and you are bound to get to a zeroing move that mates.
elcabesa
Posts: 855
Joined: Sun May 23, 2010 1:32 pm

Re: question about syzygy probing

Post by elcabesa »

thank you all!!

can you point me to some good reading about tablebase teory, it seems very interesting
syzygy
Posts: 5566
Joined: Tue Feb 28, 2012 11:56 pm

Re: question about syzygy probing

Post by syzygy »

elcabesa wrote:thank you all!!

can you point me to some good reading about tablebase teory, it seems very interesting
You could start here:
https://en.wikipedia.org/wiki/Endgame_tablebase
https://chessprogramming.wikispaces.com ... Tablebases
elcabesa
Posts: 855
Joined: Sun May 23, 2010 1:32 pm

Re: question about syzygy probing

Post by elcabesa »

I have another question about the root node search.
State of the art is filtering out bad moves in root and let the search choose the move it like the most?
Dirt
Posts: 2851
Joined: Wed Mar 08, 2006 10:01 pm
Location: Irvine, CA, USA

Re: question about syzygy probing

Post by Dirt »

elcabesa wrote:I have another question about the root node search.
State of the art is filtering out bad moves in root and let the search choose the move it like the most?
It's all a matter of what you prefer. Now, I like the idea that in KBNR vs K that you should quickly sacrifice the rook to reach a winning KBN vs K position, but many people think that's stupid. It almost certainly won't lead to the shortest checkmate.
Deasil is the right way to go.