Skip to content

Commit f594089

Browse files
Godsdarvondele
authored andcommitted
Scale the single-root-move time cap in nodestime mode
The single-root-move time cap is expressed in milliseconds, but `totalTime` and `elapsed()` use nodes when `nodestime` is enabled. The unscaled `500.0` therefore caps the allocation at 500 nodes regardless of the configured nodes per millisecond. Scale this cap by `limits.npmsec`, using 1 when nodestime is disabled. This affects positions with one legal move and searches restricted to one root move with `searchmoves`. The existing 0.5-second policy is unchanged with the default `nodestime=0`. To reproduce, send these commands interactively and wait for `bestmove`: ```text setoption name nodestime value 1000 ucinewgame isready position fen 7k/8/8/8/8/r7/1N6/K7 w - - 0 1 go wtime 120000 btime 120000 nodes 2000000 ``` Against master `effdc3fd3f6de6e75fe1374a51a7a7eed66f880b`, with one thread and the default network: | nodestime | Master nodes / depth | Patched nodes / depth | | --- | --- | --- | | 1 | 666 / 8 | 666 / 8 | | 10 | 666 / 8 | 13351 / 11 | | 100 | 666 / 8 | 54330 / 14 | | 1000 | 666 / 8 | 591911 / 28 | The cap is checked between iterations, so these node counts can exceed the allocation. The same issue and correction were reproduced with Black to move and with `position startpos` plus `searchmoves e2e4`. Unrestricted start-position searches retained identical node counts, depths, and best moves at all four nodestime settings. Validation: all 75 instrumented tests passed in both optimized and ASan+UBSan debug builds on Apple Silicon; the 16-case reproduction matrix also passed with sanitizers. Clang-format 20.1.8 and the signature test passed. Default bench unchanged: **1559611**. No Fishtest run or playing-strength gain is claimed. closes #7238 No functional change
1 parent 7316ef4 commit f594089

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎src/search.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ bool Search::Worker::iterative_deepening() {
612612

613613
if (rootMoves.size() == 1)
614614
// Cap used time to 0.5s for a better viewer experience
615-
totalTime = std::min(500.0, totalTime);
615+
totalTime = std::min(500.0 * std::max(limits.npmsec, TimePoint(1)), totalTime);
616616

617617
auto elapsedTime = elapsed();
618618

0 commit comments

Comments
 (0)