From 0e32287af470dee230a30d9f513682c3ce798668 Mon Sep 17 00:00:00 2001 From: peregrineshahin Date: Thu, 14 Sep 2023 14:15:43 +0300 Subject: [PATCH] Reorder some lines Now that qsearch has its own repetition detection we can flip the order of lines and remove the guard of depth < 0 which is not needed after reordering (i.e. it was there to prevent checking repetition again at depth ==0). Passed STC: https://tests.stockfishchess.org/tests/view/6502ecbb2cd016da89abc3fb LLR: 2.93 (-2.94,2.94) <-1.75,0.25> Total: 69536 W: 17668 L: 17490 D: 34378 Ptnml(0-2): 190, 7652, 18929, 7784, 213 Passed LTC: https://tests.stockfishchess.org/tests/view/6505ce9072620bc881ea9086 LLR: 2.94 (-2.94,2.94) <-1.75,0.25> Total: 52116 W: 13294 L: 13113 D: 25709 Ptnml(0-2): 26, 5176, 15471, 5361, 24 closes https://github.com/official-stockfish/Stockfish/pull/4791 No functional change --- src/search.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index 4b403c49..cae91018 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -525,6 +525,10 @@ namespace { constexpr bool PvNode = nodeType != NonPV; constexpr bool rootNode = nodeType == Root; + // Dive into quiescence search when the depth reaches zero + if (depth <= 0) + return qsearch(pos, ss, alpha, beta); + // Check if we have an upcoming move that draws by repetition, or // if the opponent had an alternative move earlier to this position. if ( !rootNode @@ -536,10 +540,6 @@ namespace { return alpha; } - // Dive into quiescence search when the depth reaches zero - if (depth <= 0) - return qsearch(pos, ss, alpha, beta); - assert(-VALUE_INFINITE <= alpha && alpha < beta && beta <= VALUE_INFINITE); assert(PvNode || (alpha == beta - 1)); assert(0 < depth && depth < MAX_PLY); @@ -1407,8 +1407,7 @@ moves_loop: // When in check, search starts here // Check if we have an upcoming move that draws by repetition, or // if the opponent had an alternative move earlier to this position. - if ( depth < 0 - && alpha < VALUE_DRAW + if ( alpha < VALUE_DRAW && pos.has_game_cycle(ss->ply)) { alpha = value_draw(pos.this_thread()); -- 2.39.2