From 4b085c4777c36939bd0a598f4bc3e0c04606e31b Mon Sep 17 00:00:00 2001 From: xoto10 <23479932+xoto10@users.noreply.github.com> Date: Fri, 19 May 2023 19:58:18 +0100 Subject: [PATCH] Simplify optimism calculation This change removes one of the constants in the calculation of optimism. It also changes the 2 constants used with the scale value so that they are independent, instead of applying a constant to the scale and then adjusting it again when it is applied to the optimism. This might make the tuning of these constants cleaner and more reliable in the future. STC 10+0.1 (accidentally run as an Elo gainer: LLR: 2.93 (-2.94,2.94) <0.00,2.00> Total: 154080 W: 41119 L: 40651 D: 72310 Ptnml(0-2): 375, 16840, 42190, 17212, 423 https://tests.stockfishchess.org/tests/live_elo/64653eabf3b1a4e86c317f77 LTC 60+0.6: LLR: 2.95 (-2.94,2.94) <-1.75,0.25> Total: 217434 W: 58382 L: 58363 D: 100689 Ptnml(0-2): 66, 21075, 66419, 21088, 69 https://tests.stockfishchess.org/tests/live_elo/6465d077f3b1a4e86c318d6c closes https://github.com/official-stockfish/Stockfish/pull/4576 bench: 3190961 --- src/evaluate.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index d8f4e2e1..cc789e35 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -1063,7 +1063,7 @@ Value Eval::evaluate(const Position& pos) { else { int nnueComplexity; - int scale = 967 + pos.non_pawn_material() / 64; + int npm = pos.non_pawn_material() / 64; Color stm = pos.side_to_move(); Value optimism = pos.this_thread()->optimism[stm]; @@ -1071,12 +1071,12 @@ Value Eval::evaluate(const Position& pos) { Value nnue = NNUE::evaluate(pos, true, &nnueComplexity); // Blend nnue complexity with (semi)classical complexity - nnueComplexity = ( 402 * nnueComplexity - + (454 + optimism) * abs(psq - nnue) + nnueComplexity = ( 397 * nnueComplexity + + (477 + optimism) * abs(psq - nnue) ) / 1024; - optimism = optimism * (274 + nnueComplexity) / 256; - v = (nnue * scale + optimism * (scale - 791)) / 1024; + optimism += optimism * nnueComplexity / 256; + v = (nnue * (945 + npm) + optimism * (174 + npm)) / 1024; } // Damp down the evaluation linearly when shuffling -- 2.39.2