From 009632c465ef8204884b01c0307f7e15106fd94e Mon Sep 17 00:00:00 2001 From: mstembera Date: Fri, 16 May 2025 13:04:10 -0700 Subject: [PATCH] Simplify handling of good/bad quiets Simplify the handling of good/bad quiets and make it more similar to the way we handle good/bad captures. The good quiet limit was adjusted from -7998 to -14000 to keep the ratio of good/bad quiets about the same as master. This also fixes a "bug" that previously returned some bad quiets during the GOOD_QUIET stage when some qood quiets weren't sorted at low depths. STC https://tests.stockfishchess.org/tests/view/6827a68c6ec7634154f9992b LLR: 2.93 (-2.94,2.94) <-1.75,0.25> Total: 75936 W: 19722 L: 19547 D: 36667 Ptnml(0-2): 186, 8937, 19589, 9028, 228 LTC https://tests.stockfishchess.org/tests/view/6828f8096ec7634154f99b82 LLR: 2.94 (-2.94,2.94) <-1.75,0.25> Total: 104112 W: 26773 L: 26638 D: 50701 Ptnml(0-2): 51, 11363, 29098, 11488, 56 closes https://github.com/official-stockfish/Stockfish/pull/6071 Bench: 2007023 --- src/movepick.cpp | 22 +++++++++------------- src/movepick.h | 2 +- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/movepick.cpp b/src/movepick.cpp index 1c278147f..b0059bd31 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -208,8 +208,6 @@ Move MovePicker::select(Pred filter) { // picking the move with the highest score from a list of generated moves. Move MovePicker::next_move() { - auto quiet_threshold = [](Depth d) { return -3560 * d; }; - top: switch (stage) { @@ -250,24 +248,22 @@ top: case QUIET_INIT : if (!skipQuiets) { - endMoves = beginBadQuiets = endBadQuiets = generate(pos, cur); + cur = endBadQuiets = endBadCaptures; + endMoves = generate(pos, cur); score(); - partial_insertion_sort(cur, endMoves, quiet_threshold(depth)); + partial_insertion_sort(cur, endMoves, -3560 * depth); } ++stage; [[fallthrough]]; case GOOD_QUIET : - if (!skipQuiets && select([]() { return true; })) - { - if ((cur - 1)->value > -7998 || (cur - 1)->value <= quiet_threshold(depth)) - return *(cur - 1); - - // Remaining quiets are bad - beginBadQuiets = cur - 1; - } + if (!skipQuiets && select([&]() { + return cur->value > -14000 ? true + : (*endBadQuiets++ = *cur, false); + })) + return *(cur - 1); // Prepare the pointers to loop over the bad captures cur = moves; @@ -281,7 +277,7 @@ top: return *(cur - 1); // Prepare the pointers to loop over the bad quiets - cur = beginBadQuiets; + cur = endBadCaptures; endMoves = endBadQuiets; ++stage; diff --git a/src/movepick.h b/src/movepick.h index 72a6f4e1c..7da7c3a7e 100644 --- a/src/movepick.h +++ b/src/movepick.h @@ -68,7 +68,7 @@ class MovePicker { const PieceToHistory** continuationHistory; const PawnHistory* pawnHistory; Move ttMove; - ExtMove * cur, *endMoves, *endBadCaptures, *beginBadQuiets, *endBadQuiets; + ExtMove * cur, *endMoves, *endBadCaptures, *endBadQuiets; int stage; int threshold; Depth depth;