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

Remove compensation factor to adjust extra time according to time control #5730

Closed
wants to merge 5 commits into from
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
3 changes: 1 addition & 2 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ void Search::Worker::start_searching() {
return;
}

main_manager()->tm.init(limits, rootPos.side_to_move(), rootPos.game_ply(), options,
main_manager()->originalTimeAdjust);
main_manager()->tm.init(limits, rootPos.side_to_move(), rootPos.game_ply(), options);
tt.new_search();

if (rootMoves.empty())
Expand Down
1 change: 0 additions & 1 deletion src/search.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ class SearchManager: public ISearchManager {
Depth depth);

Stockfish::TimeManagement tm;
double originalTimeAdjust;
int callsCnt;
std::atomic_bool ponder;

Expand Down
1 change: 0 additions & 1 deletion src/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ void ThreadPool::clear() {

main_manager()->callsCnt = 0;
main_manager()->bestPreviousScore = VALUE_INFINITE;
main_manager()->originalTimeAdjust = -1;
main_manager()->tm.clear();
}

Expand Down
10 changes: 2 additions & 8 deletions src/timeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ void TimeManagement::advance_nodes_time(std::int64_t nodes) {
void TimeManagement::init(Search::LimitsType& limits,
Color us,
int ply,
const OptionsMap& options,
double& originalTimeAdjust) {
const OptionsMap& options) {
TimePoint npmsec = TimePoint(options["nodestime"]);

// If we have no time, we don't need to fully initialize TM.
Expand Down Expand Up @@ -105,18 +104,13 @@ void TimeManagement::init(Search::LimitsType& limits,
// game time for the current move, so also cap to a percentage of available game time.
if (limits.movestogo == 0)
{
// Extra time according to timeLeft
if (originalTimeAdjust < 0)
originalTimeAdjust = 0.3285 * std::log10(timeLeft) - 0.4830;

// Calculate time constants based on current time left.
double logTimeInSec = std::log10(scaledTime / 1000.0);
double optConstant = std::min(0.00308 + 0.000319 * logTimeInSec, 0.00506);
double maxConstant = std::max(3.39 + 3.01 * logTimeInSec, 2.93);

optScale = std::min(0.0122 + std::pow(ply + 2.95, 0.462) * optConstant,
0.213 * limits.time[us] / timeLeft)
* originalTimeAdjust;
0.213 * limits.time[us] / timeLeft);

maxScale = std::min(6.64, maxConstant + ply / 12.0);
}
Expand Down
3 changes: 1 addition & 2 deletions src/timeman.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ class TimeManagement {
void init(Search::LimitsType& limits,
Color us,
int ply,
const OptionsMap& options,
double& originalTimeAdjust);
const OptionsMap& options);

TimePoint optimum() const;
TimePoint maximum() const;
Expand Down
Loading