@@ -40,6 +40,7 @@ SOFTWARE.
4040#include "tbprobe.h"
4141
4242#define TB_PIECES 7
43+ #define MAX_DTZ 100000
4344#define TB_HASHBITS (TB_PIECES < 7 ? 11 : 12)
4445#define TB_MAX_PIECE (TB_PIECES < 7 ? 254 : 650)
4546#define TB_MAX_PAWN (TB_PIECES < 7 ? 256 : 861)
@@ -2265,7 +2266,7 @@ static int root_probe_dtz(const Pos *pos, bool hasRepeated, bool useRule50, stru
22652266
22662267 // The border between draw and win lies at rank 1 or rank 900, depending
22672268 // on whether the 50-move rule is used.
2268- int bound = useRule50 ? 900 : 1 ;
2269+ int bound = useRule50 ? ( MAX_DTZ - 100 ) : 1 ;
22692270
22702271 // Probe, rank and score each move.
22712272 TbMove rootMoves [TB_MAX_MOVES ];
@@ -2301,18 +2302,18 @@ static int root_probe_dtz(const Pos *pos, bool hasRepeated, bool useRule50, stru
23012302 // Note that moves ranked 900 have dtz + cnt50 == 100, which in rare
23022303 // cases may be insufficient to win as dtz may be one off (see the
23032304 // comments before TB_probe_dtz()).
2304- int r = v > 0 ? (v + cnt50 <= 99 && !hasRepeated ? 1000 : 1000 - (v + cnt50 ))
2305- : v < 0 ? (- v * 2 + cnt50 < 100 ? -1000 : -1000 + (- v + cnt50 ))
2305+ int r = v > 0 ? (v + cnt50 <= 99 && !hasRepeated ? MAX_DTZ : MAX_DTZ - (v + cnt50 ))
2306+ : v < 0 ? (- v * 2 + cnt50 < 100 ? - MAX_DTZ : - MAX_DTZ + (- v + cnt50 ))
23062307 : 0 ;
23072308 m -> tbRank = r ;
23082309
23092310 // Determine the score to be displayed for this move. Assign at least
23102311 // 1 cp to cursed wins and let it grow to 49 cp as the position gets
23112312 // closer to a real win.
23122313 m -> tbScore = r >= bound ? TB_VALUE_MATE - TB_MAX_MATE_PLY - 1
2313- : r > 0 ? max ( 3 , r - 800 ) * TB_VALUE_PAWN / 200
2314+ : r > 0 ? max ( 3 , r - ( MAX_DTZ - 200 ) ) * TB_VALUE_PAWN / 200
23142315 : r == 0 ? TB_VALUE_DRAW
2315- : r > - bound ? min (-3 , r + 800 ) * TB_VALUE_PAWN / 200
2316+ : r > - bound ? min (-3 , r + ( MAX_DTZ - 200 ) ) * TB_VALUE_PAWN / 200
23162317 : - TB_VALUE_MATE + TB_MAX_MATE_PLY + 1 ;
23172318 }
23182319 return 1 ;
@@ -2323,7 +2324,7 @@ static int root_probe_dtz(const Pos *pos, bool hasRepeated, bool useRule50, stru
23232324// A return value of 0 means that not all probes were successful.
23242325int root_probe_wdl (const Pos * pos , bool useRule50 , struct TbRootMoves * rm )
23252326{
2326- static int WdlToRank [] = { -1000 , -899 , 0 , 899 , 1000 };
2327+ static int WdlToRank [] = { - MAX_DTZ , - MAX_DTZ + 101 , 0 , MAX_DTZ - 101 , MAX_DTZ };
23272328 static Value WdlToValue [] = {
23282329 - TB_VALUE_MATE + TB_MAX_MATE_PLY + 1 ,
23292330 TB_VALUE_DRAW - 2 ,
0 commit comments