Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VLTC time management tune #5095

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,15 +423,15 @@ void Search::Worker::iterative_deepening() {
int nodesEffort = effort[bestmove.from_sq()][bestmove.to_sq()] * 100
/ std::max(size_t(1), size_t(nodes));

double fallingEval = (66 + 14 * (mainThread->bestPreviousAverageScore - bestValue)
+ 6 * (mainThread->iterValue[iterIdx] - bestValue))
/ 616.6;
fallingEval = std::clamp(fallingEval, 0.51, 1.51);
double fallingEval = (1067 + 223 * (mainThread->bestPreviousAverageScore - bestValue)
+ 97 * (mainThread->iterValue[iterIdx] - bestValue))
/ 10000.0;
fallingEval = std::clamp(fallingEval, 0.580, 1.667);

// If the bestMove is stable over several iterations, reduce time accordingly
timeReduction = lastBestMoveDepth + 8 < completedDepth ? 1.56 : 0.69;
double reduction = (1.4 + mainThread->previousTimeReduction) / (2.17 * timeReduction);
double bestMoveInstability = 1 + 1.79 * totBestMoveChanges / threads.size();
timeReduction = lastBestMoveDepth + 8 < completedDepth ? 1.495 : 0.687;
double reduction = (1.48 + mainThread->previousTimeReduction) / (2.17 * timeReduction);
double bestMoveInstability = 1 + 1.88 * totBestMoveChanges / threads.size();

double totalTime =
mainThread->tm.optimum() * fallingEval * reduction * bestMoveInstability;
Expand All @@ -440,8 +440,8 @@ void Search::Worker::iterative_deepening() {
if (rootMoves.size() == 1)
totalTime = std::min(500.0, totalTime);

if (completedDepth >= 10 && nodesEffort >= 95
&& mainThread->tm.elapsed(threads.nodes_searched()) > totalTime * 3 / 4
if (completedDepth >= 10 && nodesEffort >= 97
&& mainThread->tm.elapsed(threads.nodes_searched()) > totalTime * 0.739
&& !mainThread->ponder)
{
threads.stop = true;
Expand All @@ -458,7 +458,7 @@ void Search::Worker::iterative_deepening() {
threads.stop = true;
}
else if (!mainThread->ponder
&& mainThread->tm.elapsed(threads.nodes_searched()) > totalTime * 0.50)
&& mainThread->tm.elapsed(threads.nodes_searched()) > totalTime * 0.506)
threads.increaseDepth = false;
else
threads.increaseDepth = true;
Expand Down
14 changes: 7 additions & 7 deletions src/timeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,17 @@ void TimeManagement::init(Search::LimitsType& limits,
if (limits.movestogo == 0)
{
// Use extra time with larger increments
double optExtra = std::clamp(1.0 + 12.5 * limits.inc[us] / limits.time[us], 1.0, 1.11);
double optExtra = limits.inc[us] < 500 ? 1.0 : 1.13;
Disservin marked this conversation as resolved.
Show resolved Hide resolved

// Calculate time constants based on current time left.
double optConstant =
std::min(0.00334 + 0.0003 * std::log10(limits.time[us] / 1000.0), 0.0049);
double maxConstant = std::max(3.4 + 3.0 * std::log10(limits.time[us] / 1000.0), 2.76);
std::min(0.00308 + 0.000319 * std::log10(limits.time[us] / 1000.0), 0.00506);
double maxConstant = std::max(3.39 + 3.01 * std::log10(limits.time[us] / 1000.0), 2.93);

optScale = std::min(0.0120 + std::pow(ply + 3.1, 0.44) * optConstant,
0.21 * limits.time[us] / double(timeLeft))
optScale = std::min(0.0122 + std::pow(ply + 2.95, 0.462) * optConstant,
0.213 * limits.time[us] / double(timeLeft))
* optExtra;
maxScale = std::min(6.9, maxConstant + ply / 12.2);
maxScale = std::min(6.64, maxConstant + ply / 12.0);
}

// x moves in y seconds (+ z increment)
Expand All @@ -117,7 +117,7 @@ void TimeManagement::init(Search::LimitsType& limits,
// Limit the maximum possible time for this move
optimumTime = TimePoint(optScale * timeLeft);
maximumTime =
TimePoint(std::min(0.84 * limits.time[us] - moveOverhead, maxScale * optimumTime)) - 10;
TimePoint(std::min(0.825 * limits.time[us] - moveOverhead, maxScale * optimumTime)) - 10;

if (options["Ponder"])
optimumTime += optimumTime / 4;
Expand Down