mirror of
https://github.com/sockspls/badfish
synced 2025-04-29 16:23:09 +00:00
Fix go mate x
in multithreading
Fixes two issues with master for go mate x: - when running go mate x in losing positions, master always goes to the maximal depth, arguably against what the UCI protocol demands - when running go mate x in winning positions with multiple threads, master may return non-mate scores from the search (this issue is present in stockfish since at least sf16) The issues are fixed by (a) also checking if score is mate -x and by (b) only letting mainthread stop the search for go mate x commands, and by not looking for a best thread but using mainthread as per the default. Related: niklasf/python-chess#1070 More diagnostics can be found here peregrineshahin#6 (comment) closes https://github.com/official-stockfish/Stockfish/pull/5094 No functional change Co-Authored-By: Robert Nürnberg <28635489+robertnurnberg@users.noreply.github.com>
This commit is contained in:
parent
6136d094c5
commit
748791f80d
1 changed files with 10 additions and 6 deletions
|
@ -187,7 +187,7 @@ void Search::Worker::start_searching() {
|
|||
Skill skill =
|
||||
Skill(options["Skill Level"], options["UCI_LimitStrength"] ? int(options["UCI_Elo"]) : 0);
|
||||
|
||||
if (int(options["MultiPV"]) == 1 && !limits.depth && !skill.enabled()
|
||||
if (int(options["MultiPV"]) == 1 && !limits.depth && !limits.mate && !skill.enabled()
|
||||
&& rootMoves[0].pv[0] != Move::none())
|
||||
bestThread = threads.get_best_thread()->worker.get();
|
||||
|
||||
|
@ -399,14 +399,18 @@ void Search::Worker::iterative_deepening() {
|
|||
lastBestMoveDepth = rootDepth;
|
||||
}
|
||||
|
||||
// Have we found a "mate in x"?
|
||||
if (limits.mate && bestValue >= VALUE_MATE_IN_MAX_PLY
|
||||
&& VALUE_MATE - bestValue <= 2 * limits.mate)
|
||||
threads.stop = true;
|
||||
|
||||
if (!mainThread)
|
||||
continue;
|
||||
|
||||
// Have we found a "mate in x"?
|
||||
if (limits.mate && rootMoves[0].score == rootMoves[0].uciScore
|
||||
&& ((rootMoves[0].score >= VALUE_MATE_IN_MAX_PLY
|
||||
&& VALUE_MATE - rootMoves[0].score <= 2 * limits.mate)
|
||||
|| (rootMoves[0].score != -VALUE_INFINITE
|
||||
&& rootMoves[0].score <= VALUE_TB_LOSS_IN_MAX_PLY
|
||||
&& VALUE_MATE + rootMoves[0].score <= 2 * limits.mate)))
|
||||
threads.stop = true;
|
||||
|
||||
// If the skill level is enabled and time is up, pick a sub-optimal best move
|
||||
if (skill.enabled() && skill.time_to_pick(rootDepth))
|
||||
skill.pick_best(rootMoves, multiPV);
|
||||
|
|
Loading…
Add table
Reference in a new issue