From 0470bcef0e1962b4f8da15108170b991d3f90d0e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ste=CC=81phane=20Nicolet?= Date: Tue, 22 Jun 2021 09:08:37 +0200 Subject: [PATCH] Detect fortresses a little bit quicker In the so-called "hybrid" method of evaluation of current master, we use the classical eval (because of its speed) instead of the NNUE eval when the classical material balance approximation hints that the position is "winning enough" to rely on the classical eval. This trade-off idea between speed and accuracy works well in general, but in some fortress positions the classical eval is just bad. So in shuffling branches of the search tree, we (slowly) increase the thresehold so that eventually we don't trust classical anymore and switch to NNUE evaluation. This patch increases that threshold faster, so that we switch to NNUE quicker in shuffling branches. Idea is to incite Stockfish to spend less time in fortresses lines in the search tree, and spend more time searching the critical lines. passed STC: LLR: 2.96 (-2.94,2.94) <-0.50,2.50> Total: 47872 W: 3908 L: 3720 D: 40244 Ptnml(0-2): 122, 3053, 17419, 3199, 143 https://tests.stockfishchess.org/tests/view/60cef34b457376eb8bcab79d passed LTC: LLR: 2.93 (-2.94,2.94) <0.50,3.50> Total: 73616 W: 2326 L: 2143 D: 69147 Ptnml(0-2): 21, 1940, 32705, 2119, 23 https://tests.stockfishchess.org/tests/view/60cf6d842114332881e73528 Retested at LTC against lastest master: LLR: 2.93 (-2.94,2.94) <0.50,3.50> Total: 18264 W: 642 L: 532 D: 17090 Ptnml(0-2): 6, 479, 8055, 583, 9 https://tests.stockfishchess.org/tests/view/60d18cd540925195e7a6c351 closes https://github.com/official-stockfish/Stockfish/pull/3578 Bench: 5139233 --- src/evaluate.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 6a032fc0..f9754795 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -192,8 +192,7 @@ namespace { // Threshold for lazy and space evaluation constexpr Value LazyThreshold1 = Value(1565); constexpr Value LazyThreshold2 = Value(1102); - constexpr Value SpaceThreshold = Value(11551); - constexpr Value NNUEThreshold1 = Value(800); + constexpr Value SpaceThreshold = Value(11551); // KingAttackWeights[PieceType] contains king attack weights by piece type constexpr int KingAttackWeights[PIECE_TYPE_NB] = { 0, 0, 81, 52, 44, 10 }; @@ -1103,14 +1102,14 @@ Value Eval::evaluate(const Position& pos) { return nnue; }; - // If there is PSQ imbalance we use the classical eval. + // If there is PSQ imbalance we use the classical eval, but we switch to + // NNUE eval faster when shuffling or if the material on the board is high. + int r50 = pos.rule50_count(); Value psq = Value(abs(eg_value(pos.psq_score()))); - int r50 = 16 + pos.rule50_count(); - bool largePsq = psq * 16 > (NNUEThreshold1 + pos.non_pawn_material() / 64) * r50; - - v = largePsq ? Evaluation(pos).value() // classical - : adjusted_NNUE(); // NNUE + bool classical = psq * 5 > (750 + pos.non_pawn_material() / 64) * (5 + r50); + v = classical ? Evaluation(pos).value() // classical + : adjusted_NNUE(); // NNUE } // Damp down the evaluation linearly when shuffling -- 2.39.2