mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-06 10:53:50 +08:00
Do not change TB cursed wins to draws if requested
If Syzygy50MoveRule is false, do not calls to is_draw() need to be guarded. Also fixes a TB rootmove ranking issue in this case. closes https://github.com/official-stockfish/Stockfish/pull/5814 No functional change
This commit is contained in:
committed by
Joost VandeVondele
parent
75b75bc16a
commit
6c7c5c7e47
@@ -1187,11 +1187,12 @@ bool Position::is_draw(int ply) const {
|
||||
if (st->rule50 > 99 && (!checkers() || MoveList<LEGAL>(*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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user