mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-25 11:36:51 +08:00
Fix mated-in behaviour
This addresses the issue where Stockfish may output non-proven checkmate scores if the search is prematurely halted, either due to a time control or node limit, before it explores other possibilities where the checkmate score could have been delayed or refuted. The fix also replaces staving off from proven mated scores in a multithread environment making use of the threads instead of a negative effect with multithreads (1t was better in proving mated in scores than more threads). Issue reported on mate tracker repo by and this PR is co-authored with @robertnurnberg Special thanks to @AndyGrant for outlining that a fix is eventually possible. Passed Adj off SMP STC: https://tests.stockfishchess.org/tests/view/65a125d779aa8af82b96c3eb LLR: 2.96 (-2.94,2.94) <-1.75,0.25> Total: 303256 W: 75823 L: 75892 D: 151541 Ptnml(0-2): 406, 35269, 80395, 35104, 454 Passed Adj off SMP LTC: https://tests.stockfishchess.org/tests/view/65a37add79aa8af82b96f0f7 LLR: 2.94 (-2.94,2.94) <-1.75,0.25> Total: 56056 W: 13951 L: 13770 D: 28335 Ptnml(0-2): 11, 5910, 16002, 6097, 8 Passed all tests in matetrack without any better mate for opponent found in 1t and multithreads. Fixed bugs in https://github.com/official-stockfish/Stockfish/pull/4976 closes https://github.com/official-stockfish/Stockfish/pull/4990 Bench: 1308279 Co-Authored-By: Robert Nürnberg <28635489+robertnurnberg@users.noreply.github.com>
This commit is contained in:
committed by
Disservin
parent
f15e4f50aa
commit
0c7f56dea6
@@ -20,8 +20,6 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <deque>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
@@ -169,8 +167,8 @@ void ThreadPool::start_thinking(const OptionsMap& options,
|
||||
|
||||
main_thread()->wait_for_search_finished();
|
||||
|
||||
main_manager()->stopOnPonderhit = stop = false;
|
||||
main_manager()->ponder = ponderMode;
|
||||
main_manager()->stopOnPonderhit = stop = abortedSearch = false;
|
||||
main_manager()->ponder = ponderMode;
|
||||
|
||||
increaseDepth = true;
|
||||
|
||||
@@ -229,13 +227,23 @@ Thread* ThreadPool::get_best_thread() const {
|
||||
votes[th->worker->rootMoves[0].pv[0]] += thread_value(th);
|
||||
|
||||
for (Thread* th : threads)
|
||||
if (std::abs(bestThread->worker->rootMoves[0].score) >= VALUE_TB_WIN_IN_MAX_PLY)
|
||||
if (bestThread->worker->rootMoves[0].score >= VALUE_TB_WIN_IN_MAX_PLY)
|
||||
{
|
||||
// Make sure we pick the shortest mate / TB conversion or stave off mate the longest
|
||||
// Make sure we pick the shortest mate / TB conversion
|
||||
if (th->worker->rootMoves[0].score > bestThread->worker->rootMoves[0].score)
|
||||
bestThread = th;
|
||||
}
|
||||
else if (bestThread->worker->rootMoves[0].score != -VALUE_INFINITE
|
||||
&& bestThread->worker->rootMoves[0].score <= VALUE_TB_LOSS_IN_MAX_PLY)
|
||||
{
|
||||
// Make sure we pick the shortest mated / TB conversion
|
||||
if (th->worker->rootMoves[0].score != -VALUE_INFINITE
|
||||
&& th->worker->rootMoves[0].score < bestThread->worker->rootMoves[0].score)
|
||||
bestThread = th;
|
||||
}
|
||||
else if (th->worker->rootMoves[0].score >= VALUE_TB_WIN_IN_MAX_PLY
|
||||
|| (th->worker->rootMoves[0].score != -VALUE_INFINITE
|
||||
&& th->worker->rootMoves[0].score <= VALUE_TB_LOSS_IN_MAX_PLY)
|
||||
|| (th->worker->rootMoves[0].score > VALUE_TB_LOSS_IN_MAX_PLY
|
||||
&& (votes[th->worker->rootMoves[0].pv[0]]
|
||||
> votes[bestThread->worker->rootMoves[0].pv[0]]
|
||||
|
||||
Reference in New Issue
Block a user