From f852b0ed8f469940e9cd83e45292b147bfa628b2 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Tue, 24 May 2016 08:52:53 +0200 Subject: [PATCH] Hanlde mate position in dtz probe Stick to the original code behaviour. --- src/syzygy/tbprobe.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/syzygy/tbprobe.cpp b/src/syzygy/tbprobe.cpp index 78cc89ca..efca279c 100644 --- a/src/syzygy/tbprobe.cpp +++ b/src/syzygy/tbprobe.cpp @@ -1520,7 +1520,10 @@ int Tablebases::probe_dtz(Position& pos, ProbeState* result) minDTZ = dtz; } - return minDTZ + sign_of(minDTZ); // Convert result from 1-ply search + // Convert result from 1-ply search. Special handle a mate position, when + // there are no legal moves. Return value is somewhat arbitrary, so stick + // to the original TB code that returns -1 in this case. + return minDTZ == 0xFFFF ? - 1 : minDTZ + sign_of(minDTZ); } // Check whether there has been at least one repetition of positions