From: Shahin M. Shahin <41402573+peregrineshahin@users.noreply.github.com> Date: Thu, 10 Aug 2023 07:19:40 +0000 (+0300) Subject: Detect repetitions before they happen in qsearch X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=b7b7a3f3fa786449832bd84d501c1183290f3e3a Detect repetitions before they happen in qsearch Passed STC: https://tests.stockfishchess.org/tests/view/64d495995b17f7c21c0e29ed LLR: 2.95 (-2.94,2.94) <0.00,2.00> Total: 340288 W: 86664 L: 85910 D: 167714 Ptnml(0-2): 1030, 38855, 89697, 39455, 1107 Passed LTC: https://tests.stockfishchess.org/tests/view/64d5e1085b17f7c21c0e4ab5 LLR: 2.94 (-2.94,2.94) <0.50,2.50> Total: 193230 W: 49235 L: 48606 D: 95389 Ptnml(0-2): 98, 20432, 54921, 21071, 93 closes https://github.com/official-stockfish/Stockfish/pull/4742 Bench: 1579576 --- diff --git a/src/search.cpp b/src/search.cpp index 03d72b95..44e13dae 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -1410,6 +1410,18 @@ moves_loop: // When in check, search starts here assert(PvNode || (alpha == beta - 1)); assert(depth <= 0); + // 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 + && pos.rule50_count() >= 3 + && alpha < VALUE_DRAW + && pos.has_game_cycle(ss->ply)) + { + alpha = value_draw(pos.this_thread()); + if (alpha >= beta) + return alpha; + } + Move pv[MAX_PLY+1]; StateInfo st; ASSERT_ALIGNED(&st, Eval::NNUE::CacheLineSize);