From fa3b4ef5af7535b286e97d7296c788926e7c5203 Mon Sep 17 00:00:00 2001 From: pb00067 Date: Thu, 30 Oct 2025 14:31:23 +0100 Subject: [PATCH] Improve retrograde analisys and matefinding capability fixes https://github.com/official-stockfish/Stockfish/issues/6328 Before calling search(depth), the patch ensures that depth is at least 1 whenever we encounter a decisive score in the transposition table (TT). This prevents search(depth) from being executed by qsearch, which would otherwise ignore that information. Typically, decisive TT hits occur when analyzing a mating sequence backward. Due to the nature of Iterative Deepening (IID), such scores are usually first found at depth 0. Without this patch, valuable information can be lost because qsearch may overwrite the TT entry by replacing the value with a static evaluation, even though the node was already processed at a higher depth. This is also why the engine sometimes loses track of an already discovered mate. Using ..\sf\patch.exe on matetrack.epd with --nodes 1000000 Engine ID: Stockfish dev-20251015-nogit Total FENs: 6554 Found mates: 3437 Best mates: 2438 Using ..\sf\master.exe on matetrack.epd with --nodes 1000000 Engine ID: Stockfish dev-20251015-nogit Total FENs: 6554 Found mates: 3337 Best mates: 2407 Passed STC https://tests.stockfishchess.org/tests/view/68fa3fa7637acd2a11e72a79 LLR: 3.55 (-2.94,2.94) <0.00,2.00> Total: 134144 W: 34960 L: 34471 D: 64713 Ptnml(0-2): 376, 14199, 37459, 14636, 402 Failed LTC https://tests.stockfishchess.org/tests/view/68ffc1b5637acd2a11e73377 LLR: -3.10 (-2.94,2.94) <0.50,2.50> Total: 75360 W: 19423 L: 19519 D: 36418 Ptnml(0-2): 38, 7553, 22605, 7435, 49 closes https://github.com/official-stockfish/Stockfish/pull/6386 bench: 2530552 --- src/search.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/search.cpp b/src/search.cpp index ef87c828e..151b4c6ee 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -1260,7 +1260,10 @@ moves_loop: // When in check, search starts here (ss + 1)->pv[0] = Move::none(); // Extend move from transposition table if we are about to dive into qsearch. - if (move == ttData.move && ttData.depth > 1 && rootDepth > 8) + // decisive score handling improves mate finding and retrograde analysis. + if (move == ttData.move + && ((is_valid(ttData.value) && is_decisive(ttData.value) && ttData.depth > 0) + || (ttData.depth > 1 && rootDepth > 8))) newDepth = std::max(newDepth, 1); value = -search(pos, ss + 1, -beta, -alpha, newDepth, false);