Allow time checking after each DTZ probe

This PR allows for time checking within Tablebases::rank_root_moves(). The
principal application for now is syzygy_extend_pv().

In the past, Stockfish suffered some time losses at e.g. TCEC when the HDD with
the DTZ tables was too slow for the chosen move overhead setting, see #5894.

```
> ./fastchess -engine name="patch" cmd=./stockfish.patch -engine name="master" cmd=./stockfish.master -each tc=10+0.1 option.SyzygyPath=/disk1/syzygy/3-4-5-6/WDL:/disk2/syzygy/3-4-5-6/DTZ -draw movenumber=34 movecount=8 score=20 -openings file=UHO_Lichess_4852_v1.epd format=epd -rounds 50 -repeat -concurrency 16
...
Results of patch vs master (10+0.1, 1t, 16MB, UHO_Lichess_4852_v1.epd):
Elo: 59.64 +/- 35.35, nElo: 117.61 +/- 68.10
LOS: 99.96 %, DrawRatio: 56.00 %, PairsRatio: 4.50
Games: 100, Wins: 34, Losses: 17, Draws: 49, Points: 58.5 (58.50 %)
Ptnml(0-2): [0, 4, 28, 15, 3], WL/DD Ratio: 0.87
--------------------------------------------------

Player: master
  Timeouts: 19
  Crashed: 0

Finished match
```

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

No functional change
This commit is contained in:
Robert Nurnberg
2025-11-14 17:38:55 +01:00
committed by Joost VandeVondele
parent db824e26be
commit 4b71d8e202
3 changed files with 34 additions and 22 deletions
+7 -5
View File
@@ -857,8 +857,8 @@ Value Search::Worker::search(
auto futility_margin = [&](Depth d) {
Value futilityMult = 91 - 21 * !ss->ttHit;
return futilityMult * d //
- 2094 * improving * futilityMult / 1024 //
return futilityMult * d //
- 2094 * improving * futilityMult / 1024 //
- 331 * opponentWorsening * futilityMult / 1024 //
+ std::abs(correctionValue) / 158105;
};
@@ -1980,8 +1980,9 @@ void syzygy_extend_pv(const OptionsMap& options,
for (const auto& m : MoveList<LEGAL>(pos))
legalMoves.emplace_back(m);
Tablebases::Config config = Tablebases::rank_root_moves(options, pos, legalMoves);
RootMove& rm = *std::find(legalMoves.begin(), legalMoves.end(), pvMove);
Tablebases::Config config =
Tablebases::rank_root_moves(options, pos, legalMoves, false, time_abort);
RootMove& rm = *std::find(legalMoves.begin(), legalMoves.end(), pvMove);
if (legalMoves[0].tbRank != rm.tbRank)
break;
@@ -2040,7 +2041,8 @@ void syzygy_extend_pv(const OptionsMap& options,
[](const Search::RootMove& a, const Search::RootMove& b) { return a.tbRank > b.tbRank; });
// The winning side tries to minimize DTZ, the losing side maximizes it
Tablebases::Config config = Tablebases::rank_root_moves(options, pos, legalMoves, true);
Tablebases::Config config =
Tablebases::rank_root_moves(options, pos, legalMoves, true, time_abort);
// If DTZ is not available we might not find a mate, so we bail out
if (!config.rootInTB || config.cardinality > 0)