diff --git a/src/position.cpp b/src/position.cpp index 49f520e0..02614d13 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -1187,11 +1187,12 @@ bool Position::is_draw(int ply) const { if (st->rule50 > 99 && (!checkers() || MoveList(*this).size())) return true; - // Return a draw score if a position repeats once earlier but strictly - // after the root, or repeats twice before or at the root. - return st->repetition && st->repetition < ply; + return is_repetition(ply); } +// Return a draw score if a position repeats once earlier but strictly +// after the root, or repeats twice before or at the root. +bool Position::is_repetition(int ply) const { return st->repetition && st->repetition < ply; } // Tests whether there has been at least one repetition // of positions since the last capture or pawn move. diff --git a/src/position.h b/src/position.h index 0d49a60a..d955d9f9 100644 --- a/src/position.h +++ b/src/position.h @@ -163,6 +163,7 @@ class Position { int game_ply() const; bool is_chess960() const; bool is_draw(int ply) const; + bool is_repetition(int ply) const; bool upcoming_repetition(int ply) const; bool has_repeated() const; int rule50_count() const; diff --git a/src/search.cpp b/src/search.cpp index 9f29f828..f2363162 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -1949,6 +1949,7 @@ void syzygy_extend_pv(const OptionsMap& options, auto t_start = std::chrono::steady_clock::now(); int moveOverhead = int(options["Move Overhead"]); + bool rule50 = bool(options["Syzygy50MoveRule"]); // Do not use more than moveOverhead / 2 time, if time management is active auto time_abort = [&t_start, &moveOverhead, &limits]() -> bool { @@ -1986,7 +1987,7 @@ void syzygy_extend_pv(const OptionsMap& options, pos.do_move(pvMove, st); // Do not allow for repetitions or drawing moves along the PV in TB regime - if (config.rootInTB && pos.is_draw(ply)) + if (config.rootInTB && ((rule50 && pos.is_draw(ply)) || pos.is_repetition(ply))) { pos.undo_move(pvMove); ply--; @@ -2005,7 +2006,7 @@ void syzygy_extend_pv(const OptionsMap& options, // Step 2, now extend the PV to mate, as if the user explored syzygy-tables.info // using top ranked moves (minimal DTZ), which gives optimal mates only for simple // endgames e.g. KRvK. - while (!pos.is_draw(0)) + while (!(rule50 && pos.is_draw(0))) { if (time_abort()) break; @@ -2048,7 +2049,7 @@ void syzygy_extend_pv(const OptionsMap& options, pos.do_move(pvMove, st); } - // Finding a draw in this function is an exceptional case, that cannot happen + // Finding a draw in this function is an exceptional case, that cannot happen when rule50 is false or // during engine game play, since we have a winning score, and play correctly // with TB support. However, it can be that a position is draw due to the 50 move // rule if it has been been reached on the board with a non-optimal 50 move counter diff --git a/src/syzygy/tbprobe.cpp b/src/syzygy/tbprobe.cpp index 120e6488..cbf8dce5 100644 --- a/src/syzygy/tbprobe.cpp +++ b/src/syzygy/tbprobe.cpp @@ -1620,7 +1620,7 @@ bool Tablebases::root_probe(Position& pos, WDLScore wdl = -probe_wdl(pos, &result); dtz = dtz_before_zeroing(wdl); } - else if (pos.is_draw(1)) + else if ((rule50 && pos.is_draw(1)) || pos.is_repetition(1)) { // In case a root move leads to a draw by repetition or 50-move rule, // we set dtz to zero. Note: since we are only 1 ply from the root,