From 0dcfe096d6223ea8c5663cf72f714280a38d8506 Mon Sep 17 00:00:00 2001 From: Nonlinear2 <131959792+Nonlinear2@users.noreply.github.com> Date: Mon, 21 Apr 2025 15:13:30 +0200 Subject: [PATCH] Increase full depth search reduction when cutNode In addition to the core patch, improve the use of `isTTMove`: - this name was used to mean both `bestMove == ttData.move` and `move == ttData.move`, so i replaced the argument `isTTMove` of `update_all_stats` with `TTMove` directly. - `ttData.move == move` was still used in some places instead of `ss->isTTMove`. I replaced these to be more consistent. Passed STC: https://tests.stockfishchess.org/tests/view/68057b8f98cd372e3aea3472 LLR: 2.93 (-2.94,2.94) <0.00,2.00> Total: 38400 W: 10048 L: 9734 D: 18618 Ptnml(0-2): 102, 4360, 9956, 4686, 96 Passed LTC: https://tests.stockfishchess.org/tests/view/68057f7c98cd372e3aea3842 LLR: 2.94 (-2.94,2.94) <0.50,2.50> Total: 312666 W: 79494 L: 78616 D: 154556 Ptnml(0-2): 144, 33809, 87563, 34659, 158 closes https://github.com/official-stockfish/Stockfish/pull/6007 Bench: 1623376 --- src/search.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index b8a4b32a6..85e4d0077 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -164,7 +164,7 @@ void update_all_stats(const Position& pos, ValueList& quietsSearched, ValueList& capturesSearched, Depth depth, - bool isTTMove, + Move TTMove, int moveCount); } // namespace @@ -1098,8 +1098,9 @@ moves_loop: // When in check, search starts here lmrDepth += history / 3593; - Value futilityValue = ss->staticEval + (bestMove ? 48 : 146) + 116 * lmrDepth - + 103 * (bestValue < ss->staticEval - 128 && ss->staticEval > alpha - 50); + Value futilityValue = + ss->staticEval + (bestMove ? 48 : 146) + 116 * lmrDepth + + 103 * (bestValue < ss->staticEval - 128 && ss->staticEval > alpha - 50); // Futility pruning: parent node // (*Scaler): Generally, more frequent futility pruning @@ -1231,7 +1232,7 @@ moves_loop: // When in check, search starts here r += 1042 + allNode * 864; // For first picked move (ttMove) reduce reduction - else if (move == ttData.move) + else if (ss->isTTMove) r -= 1937; if (capture) @@ -1302,6 +1303,9 @@ moves_loop: // When in check, search starts here r -= ttMoveHistory / 8; + if (cutNode) + r += 520; + // Note that if expected reduction is high, we reduce search depth here value = -search(pos, ss + 1, -(alpha + 1), -alpha, newDepth - (r > 3495) - (r > 5510 && newDepth > 2), !cutNode); @@ -1315,7 +1319,7 @@ 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 && thisThread->rootDepth > 8) + if (ss->isTTMove && thisThread->rootDepth > 8) newDepth = std::max(newDepth, 1); value = -search(pos, ss + 1, -beta, -alpha, newDepth, false); @@ -1450,10 +1454,10 @@ moves_loop: // When in check, search starts here else if (bestMove) { update_all_stats(pos, ss, *this, bestMove, prevSq, quietsSearched, capturesSearched, depth, - bestMove == ttData.move, moveCount); + ttData.move, moveCount); if (!PvNode) { - int bonus = (ttData.move == move) ? 800 : -870; + int bonus = ss->isTTMove ? 800 : -870; ttMoveHistory << bonus; } } @@ -1877,14 +1881,14 @@ void update_all_stats(const Position& pos, ValueList& quietsSearched, ValueList& capturesSearched, Depth depth, - bool isTTMove, + Move TTMove, int moveCount) { CapturePieceToHistory& captureHistory = workerThread.captureHistory; Piece moved_piece = pos.moved_piece(bestMove); PieceType captured; - int bonus = std::min(141 * depth - 89, 1613) + 311 * isTTMove; + int bonus = std::min(141 * depth - 89, 1613) + 311 * (bestMove == TTMove); int malus = std::min(695 * depth - 215, 2808) - 31 * (moveCount - 1); if (!pos.capture_stage(bestMove))