From 8baa56b3cf74a241b830d794ae9f4943ffba3fd1 Mon Sep 17 00:00:00 2001 From: MinetaS Date: Mon, 28 Oct 2024 04:20:39 +0900 Subject: [PATCH] Assert moveCountPruning properly moveCountPruning should not be set to false again once it is set to true, otherwise it will break the internal logics of MovePicker. There have been a few tests which overlooked this. Examples: https://tests.stockfishchess.org/tests/view/671e7c0486d5ee47d953d226 https://tests.stockfishchess.org/tests/view/66a1de7b4ff211be9d4eccea No functional change --- src/search.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/search.cpp b/src/search.cpp index 6e513b458ff..f7f137a3e30 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -49,6 +49,13 @@ #include "uci.h" #include "ucioption.h" +#define WRITE_TRUE_ONCE(var, x) \ + do \ + { \ + assert(!(var) || !!(x)); \ + (var) = (x); \ + } while (0) + namespace Stockfish { namespace TB = Tablebases; @@ -996,7 +1003,7 @@ Value Search::Worker::search( if (!rootNode && pos.non_pawn_material(us) && bestValue > VALUE_TB_LOSS_IN_MAX_PLY) { // Skip quiet moves if movecount exceeds our FutilityMoveCount threshold (~8 Elo) - moveCountPruning = moveCount >= futility_move_count(improving, depth); + WRITE_TRUE_ONCE(moveCountPruning, moveCount >= futility_move_count(improving, depth)); // Reduced depth of the next LMR search int lmrDepth = newDepth - r;