From f590767b91f6e7b95ee5797b3cf32c143e50d3c2 Mon Sep 17 00:00:00 2001 From: breatn Date: Tue, 22 Apr 2025 18:54:04 +0100 Subject: [PATCH] Adaptive beta cut passed STC: LLR: 2.94 (-2.94,2.94) <0.00,2.00> Total: 197088 W: 51084 L: 50533 D: 95471 Ptnml(0-2): 547, 23201, 50577, 23592, 627 https://tests.stockfishchess.org/tests/view/680604d798cd372e3aea58fe passed LTC LLR: 2.96 (-2.94,2.94) <0.50,2.50> Total: 127950 W: 32719 L: 32214 D: 63017 Ptnml(0-2): 69, 13825, 35673, 14348, 60 https://tests.stockfishchess.org/tests/view/6805eae498cd372e3aea588a closes https://github.com/official-stockfish/Stockfish/pull/6012 bench 1579003 --- AUTHORS | 1 + src/search.cpp | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 54c5f8a2..f1675860 100644 --- a/AUTHORS +++ b/AUTHORS @@ -34,6 +34,7 @@ Artem Solopiy (EntityFX) Auguste Pop Balazs Szilagyi Balint Pfliegel +Baptiste Rech (breatn) Ben Chaney (Chaneybenjamini) Ben Koshy (BKSpurgeon) Bill Henry (VoyagerOne) diff --git a/src/search.cpp b/src/search.cpp index 85e4d007..d0841881 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -103,6 +103,18 @@ Value to_corrected_static_eval(const Value v, const int cv) { return std::clamp(v + cv / 131072, VALUE_TB_LOSS_IN_MAX_PLY + 1, VALUE_TB_WIN_IN_MAX_PLY - 1); } +int adaptive_probcut_margin(Depth depth) { + // Base margin + constexpr int base = 180; + + // Approximate log2(depth) using a fast lookup table + static constexpr int logTable[32] = {0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}; + + int logDepth = logTable[std::min(depth, 31)]; + return base + logDepth * 60 + std::min(10, (depth - 16) * 2); +}; + void update_correction_history(const Position& pos, Stack* const ss, Search::Worker& workerThread, @@ -972,7 +984,7 @@ Value Search::Worker::search( moves_loop: // When in check, search starts here // Step 12. A small Probcut idea - probCutBeta = beta + 415; + probCutBeta = beta + adaptive_probcut_margin(depth); if ((ttData.bound & BOUND_LOWER) && ttData.depth >= depth - 4 && ttData.value >= probCutBeta && !is_decisive(beta) && is_valid(ttData.value) && !is_decisive(ttData.value)) return probCutBeta;