Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not change cursed wins to draws #5805

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1952,6 +1952,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 {
Expand Down Expand Up @@ -1989,7 +1990,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.has_repeated()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pos.is_draw(ply) and pos.has_repeated() are different in how they flag 2 and 3 fold repetitions. However, it might be that pos.has_repeated() but that needs some motivation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I tried minimal changes at first, and did not want to add a new function to the code base at this stage. We may eventually have to, but I do not know.

{
pos.undo_move(pvMove);
ply--;
Expand All @@ -2008,7 +2009,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)) || pos.has_repeated()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be similar.

{
if (time_abort())
break;
Expand Down Expand Up @@ -2061,7 +2062,7 @@ void syzygy_extend_pv(const OptionsMap& options,
// We adjust the score to match the found PV. Note that a TB loss score can be
// displayed if the engine did not find a drawing move yet, but eventually search
// will figure it out (e.g. 1kq5/q2r4/5K2/8/8/8/8/7Q w - - 96 1 )
if (pos.is_draw(0))
if (rule50 && pos.is_draw(0))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here not necessarily equivalent with 3-folds, not sure we can have that case.

Copy link
Contributor Author

@robertnurnberg robertnurnberg Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since pos.is_draw(0) would flag any position after 50moves without capture or pawn move as draw, we have to guard this here by rule50 to avoid cursed wins to be changed to draws. I believe this is the only place that is strictly necessary to fix the bug. The other changes try to maintain the nice PV extension also for !rule50, without success so far it seems.

v = VALUE_DRAW;

// Undo the PV moves
Expand Down
Loading