@@ -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
0 commit comments