X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fevaluate.cpp;h=710898bc15d5929eed398c4dd120e80cf50b3f6a;hb=c065abdcafe0486cb5cfa7de12a4ac6a905a54c5;hp=d3937823fe5a6176583ac5674891a3d83ae4a79a;hpb=9a64e737cfef639f202787161498ba94466ad730;p=stockfish diff --git a/src/evaluate.cpp b/src/evaluate.cpp index d3937823..710898bc 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -1021,10 +1021,13 @@ Value Eval::evaluate(const Position& pos) { v = Evaluation(pos).value(); else { - // scale and shift NNUE for compatibility with search and classical evaluation - auto adjusted_NNUE = [&](){ return NNUE::evaluate(pos) * 5 / 4 + Tempo; }; + // Scale and shift NNUE for compatibility with search and classical evaluation + auto adjusted_NNUE = [&](){ + int mat = pos.non_pawn_material(); + return NNUE::evaluate(pos) * (1024 + mat / 32) / 1024 + Tempo; + }; - // if there is PSQ imbalance use classical eval, with small probability if it is small + // If there is PSQ imbalance use classical eval, with small probability if it is small 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; @@ -1032,9 +1035,14 @@ Value Eval::evaluate(const Position& pos) { v = classical ? Evaluation(pos).value() : adjusted_NNUE(); - // if the classical eval is small and imbalance large, use NNUE nevertheless. + // If the classical eval is small and imbalance large, use NNUE nevertheless. + // For the case of opposite colored bishops, switch to NNUE eval with + // small probability if the classical eval is less than the threshold. if ( largePsq - && abs(v) * 16 < NNUEThreshold2 * r50) + && (abs(v) * 16 < NNUEThreshold2 * r50 + || ( pos.opposite_bishops() + && abs(v) * 16 < (NNUEThreshold1 + pos.non_pawn_material() / 64) * r50 + && !(pos.this_thread()->nodes & 0xB)))) v = adjusted_NNUE(); }