// Reductions lookup table, initialized at startup
int Reductions[MAX_MOVES]; // [depth or moveNumber]
- Depth reduction(bool i, Depth d, int mn, bool rangeReduction) {
+ Depth reduction(bool i, Depth d, int mn, bool rangeReduction, Value delta, Value rootDelta) {
int r = Reductions[d] * Reductions[mn];
- return (r + 534) / 1024 + (!i && r > 904) + rangeReduction;
+ return (r + 1358 - int(delta) * 1024 / int(rootDelta)) / 1024 + (!i && r > 904) + rangeReduction;
}
constexpr int futility_move_count(bool improving, Depth depth) {
// Calculate new depth for this move
newDepth = depth - 1;
+ Value delta = beta - alpha;
+
// Step 13. Pruning at shallow depth (~200 Elo). Depth conditions are important for mate finding.
if ( !rootNode
&& pos.non_pawn_material(us)
moveCountPruning = moveCount >= futility_move_count(improving, depth);
// Reduced depth of the next LMR search
- int lmrDepth = std::max(newDepth - reduction(improving, depth, moveCount, rangeReduction > 2), 0);
+ int lmrDepth = std::max(newDepth - reduction(improving, depth, moveCount, rangeReduction > 2, delta, thisThread->rootDelta), 0);
if ( captureOrPromotion
|| givesCheck)
history += thisThread->mainHistory[us][from_to(move)];
- lmrDepth = std::max(0, lmrDepth - (beta - alpha < thisThread->rootDelta / 4));
-
// Futility pruning: parent node (~5 Elo)
if ( !ss->inCheck
&& lmrDepth < 8
|| !captureOrPromotion
|| (cutNode && (ss-1)->moveCount > 1)))
{
- Depth r = reduction(improving, depth, moveCount, rangeReduction > 2);
+ Depth r = reduction(improving, depth, moveCount, rangeReduction > 2, delta, thisThread->rootDelta);
// Decrease reduction at some PvNodes (~2 Elo)
if ( PvNode
- && bestMoveCount <= 3
- && beta - alpha >= thisThread->rootDelta / 4)
+ && bestMoveCount <= 3)
r--;
// Decrease reduction if position is or has been on the PV
&& !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--;