diff --git a/src/search.cpp b/src/search.cpp index 05d522b19..870cff54b 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -70,23 +70,6 @@ namespace { // so changing them or adding conditions that are similar requires // tests at these types of time controls. -// Futility margin -Value futility_margin(Depth d, - bool noTtCutNode, - bool improving, - bool oppWorsening, - int statScore, - int correctionValue) { - Value futilityMult = 105 - 23 * noTtCutNode; - Value improvingDeduction = improving * futilityMult * 2; - Value worseningDeduction = oppWorsening * futilityMult / 3; - Value statScoreAddition = statScore / 335; - Value correctionAddition = correctionValue / 149902; - - return futilityMult * d - improvingDeduction - worseningDeduction + statScoreAddition - + correctionAddition; -} - constexpr int futility_move_count(bool improving, Depth depth) { return (3 + depth * depth) / (2 - improving); } @@ -864,13 +847,23 @@ Value Search::Worker::search( // Step 8. Futility pruning: child node // The depth condition is important for mate finding. - if (!ss->ttPv && depth < 14 - && eval - - futility_margin(depth, cutNode && !ss->ttHit, improving, opponentWorsening, - (ss - 1)->statScore, std::abs(correctionValue)) - >= beta - && eval >= beta && (!ttData.move || ttCapture) && !is_loss(beta) && !is_win(eval)) - return beta + (eval - beta) / 3; + { + auto futility_margin = [&](Depth d) { + Value futilityMult = 105 - 23 * (cutNode && !ss->ttHit); + Value improvingDeduction = improving * futilityMult * 2; + Value worseningDeduction = opponentWorsening * futilityMult / 3; + + return futilityMult * d // + - improvingDeduction // + - worseningDeduction // + + (ss - 1)->statScore / 335 // + + std::abs(correctionValue) / 149902; + }; + + if (!ss->ttPv && depth < 14 && eval + (eval - beta) / 8 - futility_margin(depth) >= beta + && eval >= beta && (!ttData.move || ttCapture) && !is_loss(beta) && !is_win(eval)) + return beta + (eval - beta) / 3; + } // Step 9. Null move search with verification search if (cutNode && (ss - 1)->currentMove != Move::null() && eval >= beta