From 36eb9bc783d35842571d0d4313349b964892d9ca Mon Sep 17 00:00:00 2001 From: Viren6 <94880762+Viren6@users.noreply.github.com> Date: Wed, 5 Jun 2024 03:24:39 +0100 Subject: [PATCH] Use futility margin in razoring margin Uses futilityMargin * depth to set the razoring margin. This retains the quadratic depth scaling to preserve mate finding capabilities. This patch is nice because it increases the elo sensitivity of the futility margin heuristics. Passed STC: https://tests.stockfishchess.org/tests/view/665f9892fd11ae7170b4849c LLR: 2.93 (-2.94,2.94) <0.00,2.00> Total: 39392 W: 10348 L: 10030 D: 19014 Ptnml(0-2): 99, 4585, 10009, 4905, 98 Passed LTC: https://tests.stockfishchess.org/tests/view/665f9d2dfd11ae7170b484a8 LLR: 2.95 (-2.94,2.94) <0.50,2.50> Total: 107910 W: 27521 L: 27053 D: 53336 Ptnml(0-2): 73, 11835, 29670, 12305, 72 closes https://github.com/official-stockfish/Stockfish/pull/5360 bench 1277173 --- src/search.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index 1c0bbc4d..15cc2d8f 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -60,9 +60,9 @@ static constexpr double EvalLevel[10] = {0.981, 0.956, 0.895, 0.949, 0.913, // Futility margin Value futility_margin(Depth d, bool noTtCutNode, bool improving, bool oppWorsening) { - Value futilityMult = 124 - 43 * noTtCutNode; - Value improvingDeduction = 60 * improving * futilityMult / 32; - Value worseningDeduction = 344 * oppWorsening * futilityMult / 1024; + Value futilityMult = 109 - 40 * noTtCutNode; + Value improvingDeduction = 59 * improving * futilityMult / 32; + Value worseningDeduction = 328 * oppWorsening * futilityMult / 1024; return futilityMult * d - improvingDeduction - worseningDeduction; } @@ -554,7 +554,7 @@ Value Search::Worker::search( bool givesCheck, improving, priorCapture, opponentWorsening; bool capture, moveCountPruning, ttCapture; Piece movedPiece; - int moveCount, captureCount, quietCount; + int moveCount, captureCount, quietCount, futilityMargin; Bound singularBound; // Step 1. Initialize node @@ -761,10 +761,12 @@ Value Search::Worker::search( opponentWorsening = ss->staticEval + (ss - 1)->staticEval > 2; + futilityMargin = futility_margin(depth, cutNode && !ss->ttHit, improving, opponentWorsening); + // Step 7. Razoring (~1 Elo) // If eval is really low check with qsearch if it can exceed alpha, if it can't, // return a fail low. - if (eval < alpha - 512 - 293 * depth * depth) + if (eval < alpha - 465 - futilityMargin * depth * 33 / 32) { value = qsearch(pos, ss, alpha - 1, alpha); if (value < alpha) @@ -774,9 +776,7 @@ Value Search::Worker::search( // Step 8. Futility pruning: child node (~40 Elo) // The depth condition is important for mate finding. if (!ss->ttPv && depth < 13 - && eval - futility_margin(depth, cutNode && !ss->ttHit, improving, opponentWorsening) - - (ss - 1)->statScore / 263 - >= beta + && eval - futilityMargin - (ss - 1)->statScore / 263 >= beta && eval >= beta && eval < VALUE_TB_WIN_IN_MAX_PLY && (!ttMove || ttCapture)) return beta > VALUE_TB_LOSS_IN_MAX_PLY ? beta + (eval - beta) / 3 : eval;