// 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)
&& captureHistory[movedPiece][to_sq(move)][type_of(pos.piece_on(to_sq(move)))] < 0)
continue;
+ // Futility pruning for captures
+ if ( !pos.empty(to_sq(move))
+ && !givesCheck
+ && !PvNode
+ && lmrDepth < 6
+ && !ss->inCheck
+ && ss->staticEval + 342 + 238 * lmrDepth + PieceValue[EG][pos.piece_on(to_sq(move))]
+ + captureHistory[movedPiece][to_sq(move)][type_of(pos.piece_on(to_sq(move)))] / 8 < alpha)
+ continue;
+
// SEE based pruning
if (!pos.see_ge(move, Value(-218) * depth)) // (~25 Elo)
continue;
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
extension = -2;
}
- // Capture extensions for PvNodes and cutNodes
- else if ( (PvNode || cutNode)
- && captureOrPromotion
- && moveCount != 1)
- extension = 1;
-
// Check extensions
else if ( givesCheck
&& depth > 6
|| !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--;