- Depth r = reduction(improving, depth, moveCount, rangeReduction > 2);
-
- // Decrease reduction at some PvNodes (~2 Elo)
- if ( PvNode
- && bestMoveCount <= 3
- && beta - alpha >= thisThread->rootDelta / 4)
- r--;
-
- // Decrease reduction if position is or has been on the PV
- // and node is not likely to fail low. (~3 Elo)
- if ( ss->ttPv
- && !likelyFailLow)
- r -= 2;
-
- // Increase reduction at non-PV nodes (~3 Elo)
- if (!PvNode)
- r++;
-
- // Decrease reduction if opponent's move count is high (~1 Elo)
- if ((ss-1)->moveCount > 13)
- r--;
-
- // Increase reduction for cut nodes (~3 Elo)
- if (cutNode && move != ss->killers[0])
- r += 2;
-
- // Increase reduction if ttMove is a capture (~3 Elo)
- if (ttCapture)
- r++;
-
- ss->statScore = thisThread->mainHistory[us][from_to(move)]
- + (*contHist[0])[movedPiece][to_sq(move)]
- + (*contHist[1])[movedPiece][to_sq(move)]
- + (*contHist[3])[movedPiece][to_sq(move)]
- - 4923;
-
- // Decrease/increase reduction for moves with a good/bad history (~30 Elo)
- r -= ss->statScore / 14721;
-
- // In general we want to cap the LMR depth search at newDepth. But if reductions
- // are really negative and movecount is low, we allow this move to be searched
- // deeper than the first move (this may lead to hidden double extensions).
- int deeper = r >= -1 ? 0
- : moveCount <= 5 ? 2
- : PvNode && depth > 6 ? 1
- : cutNode && moveCount <= 7 ? 1
- : 0;
-
- Depth d = std::clamp(newDepth - r, 1, newDepth + deeper);
+ // In general we want to cap the LMR depth search at newDepth, but when
+ // reduction is negative, we allow this move a limited search extension
+ // beyond the first move depth. This may lead to hidden double extensions.
+ Depth d = std::clamp(newDepth - r, 1, newDepth + 1);