- const bool doDeeperSearch = value > (alpha + 64 + 11 * (newDepth - d));
- value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, newDepth + doDeeperSearch, !cutNode);
+ // Adjust full depth search based on LMR results - if result
+ // was good enough search deeper, if it was bad enough search shallower
+ const bool doDeeperSearch = value > (alpha + 58 + 12 * (newDepth - d));
+ const bool doEvenDeeperSearch = value > alpha + 588 && ss->doubleExtensions <= 5;
+ const bool doShallowerSearch = value < bestValue + newDepth;
+
+ ss->doubleExtensions = ss->doubleExtensions + doEvenDeeperSearch;
+
+ newDepth += doDeeperSearch - doShallowerSearch + doEvenDeeperSearch;
+
+ if (newDepth > d)
+ value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, newDepth, !cutNode);