X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fevaluate.cpp;h=415c18c557395cad0bd7b1bc2c5956a5daa21679;hb=7f1333ccf89c715933ead72e31233510c6f4d146;hp=718c7bc035da95f92718e73fe599ee376ff793d7;hpb=22b7909809c731aea691184dd7c1a2b02c5946af;p=stockfish diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 718c7bc0..415c18c5 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -192,7 +192,6 @@ using namespace Trace; namespace { - // Threshold for lazy and space evaluation constexpr Value LazyThreshold1 = Value(3631); constexpr Value LazyThreshold2 = Value(2084); @@ -1084,13 +1083,14 @@ make_v: Value Eval::evaluate(const Position& pos) { Value v; - bool useClassical = false; + // Deciding between classical and NNUE eval (~10 Elo): for high PSQ imbalance we use classical, + // but we switch to NNUE during long shuffling or with high material on the board. + bool useClassical = (pos.this_thread()->depth > 9 || pos.count() > 7) && + abs(eg_value(pos.psq_score())) * 5 > (856 + pos.non_pawn_material() / 64) * (10 + pos.rule50_count()); // Deciding between classical and NNUE eval (~10 Elo): for high PSQ imbalance we use classical, // but we switch to NNUE during long shuffling or with high material on the board. - if ( !useNNUE - || ((pos.this_thread()->depth > 9 || pos.count() > 7) && - abs(eg_value(pos.psq_score())) * 5 > (856 + pos.non_pawn_material() / 64) * (10 + pos.rule50_count()))) + if (!useNNUE || useClassical) { v = Evaluation(pos).value(); // classical useClassical = abs(v) >= 297; @@ -1099,15 +1099,16 @@ Value Eval::evaluate(const Position& pos) { // If result of a classical evaluation is much lower than threshold fall back to NNUE if (useNNUE && !useClassical) { - Value nnue = NNUE::evaluate(pos, true); // NNUE - int scale = 1014 + 21 * pos.non_pawn_material() / 1024; + int complexity; + int scale = 1048 + 109 * pos.non_pawn_material() / 5120; Color stm = pos.side_to_move(); Value optimism = pos.this_thread()->optimism[stm]; Value psq = (stm == WHITE ? 1 : -1) * eg_value(pos.psq_score()); - int complexity = 35 * abs(nnue - psq) / 256; + Value nnue = NNUE::evaluate(pos, true, &complexity); // NNUE - optimism = optimism * (32 + complexity) / 32; - v = (nnue * scale + optimism * (scale - 846)) / 1024; + complexity = (137 * complexity + 137 * abs(nnue - psq)) / 256; + optimism = optimism * (255 + complexity) / 256; + v = (nnue * scale + optimism * (scale - 848)) / 1024; if (pos.is_chess960()) v += fix_FRC(pos);