1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-07-11 11:39:15 +00:00

Minimal thinking time, even if only one rootMove.

without search, the eval returned can be misleading (e.g. mate instead of draw),
leading to wrong adjudication. With a minimal search, this is avoided.
This patch leads to 1ms long searches if there is only 1 move,
similar patches all indicate a small Elo gain.

Fixes https://github.com/official-stockfish/Stockfish/issues/2707

Passed non-regression STC:
LLR: 2.93 (-2.94,2.94) {-1.50,0.50}
Total: 22312 W: 4350 L: 4204 D: 13758
Ptnml(0-2): 323, 2488, 5437, 2536, 372
https://tests.stockfishchess.org/tests/view/5ed562b0f29b40b0fc95a7d0

closes https://github.com/official-stockfish/Stockfish/pull/2709

Bench: 4733799
This commit is contained in:
Moez Jellouli 2020-05-31 16:51:38 +02:00 committed by Joost VandeVondele
parent 16566a8fcf
commit 784263596f

View file

@ -556,9 +556,11 @@ void Thread::search() {
} }
double bestMoveInstability = 1 + totBestMoveChanges / Threads.size(); double bestMoveInstability = 1 + totBestMoveChanges / Threads.size();
// Stop the search if we have only one legal move, or if available time elapsed double totalTime = rootMoves.size() == 1 ? 0 :
if ( rootMoves.size() == 1 Time.optimum() * fallingEval * reduction * bestMoveInstability;
|| Time.elapsed() > Time.optimum() * fallingEval * reduction * bestMoveInstability)
// Stop the search if we have exceeded the totalTime, at least 1ms search.
if (Time.elapsed() > totalTime)
{ {
// If we are allowed to ponder do not stop the search now but // If we are allowed to ponder do not stop the search now but
// keep pondering until the GUI sends "ponderhit" or "stop". // keep pondering until the GUI sends "ponderhit" or "stop".
@ -569,7 +571,7 @@ void Thread::search() {
} }
else if ( Threads.increaseDepth else if ( Threads.increaseDepth
&& !mainThread->ponder && !mainThread->ponder
&& Time.elapsed() > Time.optimum() * fallingEval * reduction * bestMoveInstability * 0.6) && Time.elapsed() > totalTime * 0.6)
Threads.increaseDepth = false; Threads.increaseDepth = false;
else else
Threads.increaseDepth = true; Threads.increaseDepth = true;