]> git.sesse.net Git - stockfish/commitdiff
Simplify optimism calculation
authorxoto10 <23479932+xoto10@users.noreply.github.com>
Fri, 19 May 2023 18:58:18 +0000 (19:58 +0100)
committerJoost VandeVondele <Joost.VandeVondele@gmail.com>
Sat, 20 May 2023 08:05:19 +0000 (10:05 +0200)
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

index d8f4e2e194f652417612b72ce9c31b7aaf98f649..cc789e35d893cd2322b4699555df565288b27dfe 100644 (file)
@@ -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