From d29c8bd5d456b2a6fcee2069e1440ef82cba2b1e Mon Sep 17 00:00:00 2001 From: Guenther Demetz Date: Wed, 20 Nov 2024 14:48:23 +0100 Subject: [PATCH] Rewrite of 'Adjust correction history' condition Current condition is convoluted and hard to understand because of several negations. Also added 2 comments to make the concept behind the condition better understandable. closes https://github.com/official-stockfish/Stockfish/pull/5685 No functional change --- src/search.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index f1942a4f..93036398 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -1425,9 +1425,9 @@ moves_loop: // When in check, search starts here depth, bestMove, unadjustedStaticEval, tt.generation()); // Adjust correction history - if (!ss->inCheck && (!bestMove || !pos.capture(bestMove)) - && !(bestValue >= beta && bestValue <= ss->staticEval) - && !(!bestMove && bestValue >= ss->staticEval)) + if (!ss->inCheck && !(bestMove && pos.capture(bestMove)) + && ((bestValue < ss->staticEval && bestValue < beta) // negative correction & no fail high + || (bestValue > ss->staticEval && bestMove))) // positive correction & no fail low { const auto m = (ss - 1)->currentMove;