From 7e754e17dd37491745b20970a7acce6bc27d4708 Mon Sep 17 00:00:00 2001 From: "Robert Nurnberg @ elitebook" <28635489+robertnurnberg@users.noreply.github.com> Date: Mon, 4 May 2026 08:31:44 +0200 Subject: [PATCH] Simplify away completedDepth Recent changes to this part of the code mean that the variable `completedDepth` is no longer neeeded. The only *functional* part of this patch is the effect on the thread voting formula. Basically, compared to master this patch raises the depth weight in the formula uniformly by 1. For very, very low depths this may have a tiny effect on thread selection compared to master. But in general we expect this patch to have no effect on game play at STC and LTC. Passed STC SMP non-reg: LLR: 2.95 (-2.94,2.94) <-1.75,0.25> Total: 284808 W: 72944 L: 72994 D: 138870 Ptnml(0-2): 351, 32192, 77370, 32138, 353 https://tests.stockfishchess.org/tests/view/69eddd011e5788938e86a075 closes https://github.com/official-stockfish/Stockfish/pull/6793 No functional change --- src/search.cpp | 8 +++----- src/search.h | 2 +- src/thread.cpp | 6 +++--- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index b6c63f3c2..d0f8d55c7 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -461,8 +461,6 @@ bool Search::Worker::iterative_deepening() { if (!threads.stop) { - completedDepth = rootDepth; - if (lastIterationPV.empty() || rootMoves[0].pv[0] != lastIterationPV[0]) lastBestMoveDepth = rootDepth; @@ -525,9 +523,9 @@ bool Search::Worker::iterative_deepening() { fallingEval = std::clamp(fallingEval, 0.581, 1.655); // If the bestMove is stable over several iterations, reduce time accordingly - timeReduction = std::clamp( - interpolate(double(completedDepth - lastBestMoveDepth), 5.0, 18.0, 0.65, 1.55), 0.65, - 1.55); + timeReduction = + std::clamp(interpolate(double(rootDepth - lastBestMoveDepth), 5.0, 18.0, 0.65, 1.55), + 0.65, 1.55); double reduction = (1.5 + mainThread->previousTimeReduction) / (2.255 * timeReduction); diff --git a/src/search.h b/src/search.h index 3bdf3c783..50aef6aa9 100644 --- a/src/search.h +++ b/src/search.h @@ -380,7 +380,7 @@ class Worker { Position rootPos; StateInfo rootState; RootMoves rootMoves; - Depth rootDepth, completedDepth; + Depth rootDepth; Value rootDelta; PVMoves lastIterationPV; diff --git a/src/thread.cpp b/src/thread.cpp index fce27cc50..6c3c6487b 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -332,8 +332,8 @@ void ThreadPool::start_thinking(const OptionsMap& options, th->worker->limits = limits; th->worker->nodes = th->worker->tbHits = th->worker->bestMoveChanges = 0; th->worker->nmpMinPly = 0; - th->worker->rootDepth = th->worker->completedDepth = 0; - th->worker->rootMoves = rootMoves; + th->worker->rootDepth = 0; + th->worker->rootMoves = rootMoves; th->worker->rootPos.set(pos.fen(), pos.is_chess960(), &th->worker->rootState); th->worker->rootState = setupStates->back(); th->worker->tbConfig = tbConfig; @@ -360,7 +360,7 @@ Thread* ThreadPool::get_best_thread() const { // Vote according to score and depth, and select the best thread auto thread_voting_value = [minScore](Thread* th) { - return (th->worker->rootMoves[0].score - minScore + 14) * int(th->worker->completedDepth); + return (th->worker->rootMoves[0].score - minScore + 14) * int(th->worker->rootDepth); }; for (auto&& th : threads)