syzygy, phantom & best move

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
flok
Posts: 481
Joined: Tue Jul 03, 2018 10:19 am
Full name: Folkert van Heusden

syzygy, phantom & best move

Post by flok »

Hi,

Fathom (the jdart version) returns for 8/8/8/3k4/p7/2K5/P7/7r b - - 0 95 the following winning moves:

Ke4, Kc5, Ke5, Kc6, Kd6, Ke6, Ra1, Rb1, Rc1, Rd1, Re1, Rf1, Rg1, Rh2, Rh3, Rh4, Rh5, Rh6, Rh7, Rh8, a3

How do I know which one of these to pick?
Because my program (Micah) apparently lost (well, got into a draw) by always picking the first winning move (Ke4 in this example).
Ras
Posts: 2488
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: syzygy, phantom & best move

Post by Ras »

flok wrote: Tue Apr 14, 2020 9:40 pmHow do I know which one of these to pick?
If the root position is a Syzygy hit, do you make all legal root moves to see which one has the minimal DTZ? Or, if the engine is losing, maximise DTZ?
Rasmus Althoff
https://www.ct800.net
syzygy
Posts: 5566
Joined: Tue Feb 28, 2012 11:56 pm

Re: syzygy, phantom & best move

Post by syzygy »

flok wrote: Tue Apr 14, 2020 9:40 pm Hi,

Fathom (the jdart version) returns for 8/8/8/3k4/p7/2K5/P7/7r b - - 0 95 the following winning moves:

Ke4, Kc5, Ke5, Kc6, Kd6, Ke6, Ra1, Rb1, Rc1, Rd1, Re1, Rf1, Rg1, Rh2, Rh3, Rh4, Rh5, Rh6, Rh7, Rh8, a3

How do I know which one of these to pick?
Because my program (Micah) apparently lost (well, got into a draw) by always picking the first winning move (Ke4 in this example).
If Fathom correctly takes into account the 50-move counter and the full game history, this should work.

Apparently, Fathom does not do that (or your program does not give Fathom access to this information or has some other bug).

The easy solution is to pick the move that minimises DTZ (when winning). Make sure that you give preference to a winning capture or pawn move (to be treated as DTZ=0) over other moves (apart from moves that mate).

The problem with the easy solution is that the engine will play pretty ugly. The nicer solution is therefore to ask for the winning moves, search those moves a bit, and then play the winning move with the highest score. But for this to work correctly, Fathom needs to give you the winning moves and not more (and it needs to be careful when there has been one repetition, since a second repetition would be a draw - solution: play DTZ minimising moves until the 50-move counter resets).