Skip to content

Commit e6482b7

Browse files
uriblassmcostalba
authored andcommitted
Time management: move faster if PV is stable
Move faster but compensate by allocating more time when the best move changes. Passed short TC at 15+0.05 LLR: 2.93 (-2.94,2.94) Total: 13895 W: 3030 L: 2882 D: 798 Long TC at 60+0.05 LLR: 2.96 (-2.94,2.94) Total: 9266 W: 1777 L: 1624 D: 5865 At time increment 30+0.5 LLR: 2.96 (-2.94,2.94) Total: 6703 W: 1238 L: 1134 D: 4331 And at fixed game number, longer TC 120+0.05 ELO: 5.17 +-2.8 (95%) LOS: 100.0% Total: 19306 W: 3378 L: 3091 D: 12837 bench: 4728533
1 parent 6e6c5b6 commit e6482b7

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

src/search.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ namespace {
8484

8585
size_t PVSize, PVIdx;
8686
TimeManager TimeMgr;
87-
int BestMoveChanges;
87+
float BestMoveChanges;
8888
Value DrawValue[COLOR_NB];
8989
HistoryStats History;
9090
GainsStats Gains;
@@ -304,13 +304,14 @@ namespace {
304304
void id_loop(Position& pos) {
305305

306306
Stack stack[MAX_PLY_PLUS_6], *ss = stack+2; // To allow referencing (ss-2)
307-
int depth, prevBestMoveChanges;
307+
int depth;
308308
Value bestValue, alpha, beta, delta;
309309

310310
std::memset(ss-2, 0, 5 * sizeof(Stack));
311311
(ss-1)->currentMove = MOVE_NULL; // Hack to skip update gains
312312

313-
depth = BestMoveChanges = 0;
313+
depth = 0;
314+
BestMoveChanges = 0;
314315
bestValue = delta = alpha = -VALUE_INFINITE;
315316
beta = VALUE_INFINITE;
316317

@@ -332,14 +333,14 @@ namespace {
332333
// Iterative deepening loop until requested to stop or target depth reached
333334
while (++depth <= MAX_PLY && !Signals.stop && (!Limits.depth || depth <= Limits.depth))
334335
{
336+
// Age out PV variability metric
337+
BestMoveChanges *= 0.8;
338+
335339
// Save last iteration's scores before first PV line is searched and all
336340
// the move scores but the (new) PV are set to -VALUE_INFINITE.
337341
for (size_t i = 0; i < RootMoves.size(); i++)
338342
RootMoves[i].prevScore = RootMoves[i].score;
339343

340-
prevBestMoveChanges = BestMoveChanges; // Only sensible when PVSize == 1
341-
BestMoveChanges = 0;
342-
343344
// MultiPV loop. We perform a full root search for each PV line
344345
for (PVIdx = 0; PVIdx < PVSize; PVIdx++)
345346
{
@@ -437,7 +438,7 @@ namespace {
437438

438439
// Take in account some extra time if the best move has changed
439440
if (depth > 4 && depth < 50 && PVSize == 1)
440-
TimeMgr.pv_instability(BestMoveChanges, prevBestMoveChanges);
441+
TimeMgr.pv_instability(BestMoveChanges);
441442

442443
// Stop search if most of available time is already consumed. We
443444
// probably don't have enough time to search the first move at the

src/timeman.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,9 @@ namespace {
7676
}
7777

7878

79-
void TimeManager::pv_instability(int curChanges, int prevChanges) {
79+
void TimeManager::pv_instability(float bestMoveChanges) {
8080

81-
unstablePVExtraTime = curChanges * (optimumSearchTime / 2)
82-
+ prevChanges * (optimumSearchTime / 3);
81+
unstablePVExtraTime = int(bestMoveChanges * optimumSearchTime);
8382
}
8483

8584

src/timeman.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
class TimeManager {
2727
public:
2828
void init(const Search::LimitsType& limits, int currentPly, Color us);
29-
void pv_instability(int curChanges, int prevChanges);
29+
void pv_instability(float bestMoveChanges);
3030
int available_time() const { return optimumSearchTime + unstablePVExtraTime; }
3131
int maximum_time() const { return maximumSearchTime; }
3232

src/ucioption.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void init(OptionsMap& o) {
8383
o["Emergency Base Time"] = Option(200, 0, 30000);
8484
o["Emergency Move Time"] = Option(70, 0, 5000);
8585
o["Minimum Thinking Time"] = Option(20, 0, 5000);
86-
o["Slow Mover"] = Option(100, 10, 1000);
86+
o["Slow Mover"] = Option(50, 10, 1000);
8787
o["UCI_Chess960"] = Option(false);
8888
o["UCI_AnalyseMode"] = Option(false, on_eval);
8989
}

0 commit comments

Comments
 (0)