Syzygy question

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

jdart
Posts: 4366
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Syzygy question

Post by jdart »

I am looking at this position:

[D] 8/B3k3/1n6/8/3K4/7B/8/8 b - - 0 1

White has just played BxP (on a7), so the 50-move counter is at zero. Nalimov TBs say this is a mate in 58 moves for White (after .. Nd7). But that is outside the 50-move limit, so this should be a draw.

However, both Arasan, using the Fathom library, and Stockfish 9 report that Black (to move) is losing. In the game this is from, Arasan had White, and it gave a win score all the way up to the point where it hit the 50-move limit, and then it reported a draw.

This is Stockfish output:

position fen 8/B3k3/1n6/8/3K4/7B/8/8 b - - 0 1
setoption name SyzygyPath value \chess\syzygy
info string Found 145 tablebases
go depth 6
info depth 1 seldepth 1 multipv 1 score cp -13279 nodes 1 nps 500 tbhits 1 time 2 pv b6d7
info depth 2 seldepth 2 multipv 1 score cp -13279 nodes 13 nps 6500 tbhits 1 time 2 pv b6d7 h3g2
info depth 3 seldepth 3 multipv 1 score cp -13279 nodes 51 nps 17000 tbhits 1 time 3 pv b6d7 h3f5 d7f6
info depth 4 seldepth 5 multipv 1 score cp -13279 nodes 318 nps 106000 tbhits 1 time 3 pv b6d7 d4d5 d7e5 d5e5
info depth 5 seldepth 6 multipv 1 score cp -13279 nodes 453 nps 113250 tbhits 1 time 4 pv b6d7 d4d5 d7f6 d5e5 f6d7 e5e4
info depth 6 seldepth 8 multipv 1 score cp -13279 nodes 829 nps 207250 tbhits 1 time 4 pv b6d7 d4d5 d7f6 d5c6 f6e4 h3g4 e4d6
bestmove b6d7 ponder d4d5

Stockfish has Syzygy50MoveRule set "true" (the default).

Am I missing something? Is this expected behavior?

--Jon
syzygy
Posts: 5557
Joined: Tue Feb 28, 2012 11:56 pm

Re: Syzygy question

Post by syzygy »

jdart wrote: Mon May 14, 2018 10:01 pm I am looking at this position:

[D] 8/B3k3/1n6/8/3K4/7B/8/8 b - - 0 1

White has just played BxP (on a7), so the 50-move counter is at zero. Nalimov TBs say this is a mate in 58 moves for White (after .. Nd7). But that is outside the 50-move limit, so this should be a draw.
https://syzygy-tables.info/?fen=8/B3k3/ ... _b_-_-_0_1
Distance to zero is 92 plies, so this is a win for white.

It is also 58 moves to mate. So if white uses Syzygy TBs and black uses Nalimov TBs, white will take at least 58 moves to mate, but in the process it will capture black's knight before the 50-move counter runs out. (If you let the TBs switch sides, it is possible that Nalimov as white runs into a 50-move draw.)
However, both Arasan, using the Fathom library, and Stockfish 9 report that Black (to move) is losing. In the game this is from, Arasan had White, and it gave a win score all the way up to the point where it hit the 50-move limit, and then it reported a draw.
Then Arasan does not correctly handle TB probes at the root.

The engine should make sure that it does not select a non-winning move (taking into account the 50-move rule). And some care is needed to prevent an unlucky draw by repetition.

The easiest solution is to just always pick a move that minimizes DTZ (counted from the current board position, so winning captures, pawn moves and mating moves have DTZ=1, all other moves DTZ > 1 or do not win). But this leads to very ugly play in some positions.
syzygy
Posts: 5557
Joined: Tue Feb 28, 2012 11:56 pm

Re: Syzygy question

Post by syzygy »

What I do not know is how much of this is (should be) taken care of by the Fathom library.
Sesse
Posts: 300
Joined: Mon Apr 30, 2018 11:51 pm

Re: Syzygy question

Post by Sesse »

What we need are clearly DTM50 bases :-)
jdart
Posts: 4366
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: Syzygy question

Post by jdart »

FYI, this issue was caused by not filtering correctly in the search according to the move list returned by the Fathom code (the list of moves that preserves a win, if there is one). This was a regression caused by the recent LazySMP changes. It is fixed now and Arasan is able to win this endgame.

Fathom itself doesn't handle the case where a repetition occurs and the nearest DTZ move should be played, but this is easy handled by the caller to the library.

--Jon
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Syzygy question

Post by Sven »

Sesse wrote: Mon May 14, 2018 11:59 pm What we need are clearly DTM50 bases :-)
The most recent work on DTM50 that I am aware of is described in the EGTB forum, in an article by Galen Huntington and Guy Haworth and on this page of Galen Huntington. Does anyone know about newer sources?
Sven Schüle (engine author: Jumbo, KnockOut, Surprise)
Sesse
Posts: 300
Joined: Mon Apr 30, 2018 11:51 pm

Re: Syzygy question

Post by Sesse »

To be honest, not even DTM50 will always give the right answer, due to possible three-fold repetitions.
Dann Corbit
Posts: 12537
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Syzygy question

Post by Dann Corbit »

Sesse wrote: Tue May 22, 2018 12:04 am To be honest, not even DTM50 will always give the right answer, due to possible three-fold repetitions.
If the repetitions are avoidable, the programmer can examine every mate path calculable with the DTM50 tables.
If the repetition can be avoided, then the programmer can avoid it. If not, then it could not be avoided anyway.
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.
syzygy
Posts: 5557
Joined: Tue Feb 28, 2012 11:56 pm

Re: Syzygy question

Post by syzygy »

Sesse wrote: Tue May 22, 2018 12:04 am To be honest, not even DTM50 will always give the right answer, due to possible three-fold repetitions.
If the engine has control from the moment the game reaches a winning TB position, a three-fold repetition will not occur if the engine plays DTM50-optimal moves.

If the game first enters a TB position that is drawn and the opponent makes a mistake, then from that point on the engine can play DTM50-optimal moves and avoid a repetition. All positions that occurred earlier were not winning, so those positions will not be repeated.

But you are right that given a TB position with arbitrary game history (e.g. played by 2 humans), the DTM50 table can be wrong.
syzygy
Posts: 5557
Joined: Tue Feb 28, 2012 11:56 pm

Re: Syzygy question

Post by syzygy »

Dann Corbit wrote: Tue May 22, 2018 1:01 am
Sesse wrote: Tue May 22, 2018 12:04 am To be honest, not even DTM50 will always give the right answer, due to possible three-fold repetitions.
If the repetitions are avoidable, the programmer can examine every mate path calculable with the DTM50 tables.
If that were an option, you could as well directly examine every possible path and not use any tables at all.