Evaluation adjustment for different eval types

Gives different eval scaling parameters for the three different types
of evaluation (bignet, smallnet, psqtOnly).

Passed STC:
https://tests.stockfishchess.org/tests/view/65f4b0020ec64f0526c4a3bd
LLR: 2.96 (-2.94,2.94) <0.00,2.00>
Total: 168064 W: 43507 L: 42987 D: 81570
Ptnml(0-2): 662, 19871, 42445, 20393, 661

Passed LTC:
https://tests.stockfishchess.org/tests/view/65f6be1a0ec64f0526c4c361
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 162564 W: 41188 L: 40604 D: 80772
Ptnml(0-2): 120, 18112, 44216, 18732, 102

closes https://github.com/official-stockfish/Stockfish/pull/5122

Bench: 2113576
This commit is contained in:
Gahtan Nahdi
2024-03-15 16:50:27 +07:00
committed by Disservin
parent 9b92ada935
commit 1a6c22c511
2 changed files with 24 additions and 11 deletions

View File

@@ -52,22 +52,35 @@ Value Eval::evaluate(const Eval::NNUE::Networks& networks, const Position& pos,
int simpleEval = simple_eval(pos, pos.side_to_move()); int simpleEval = simple_eval(pos, pos.side_to_move());
bool smallNet = std::abs(simpleEval) > SmallNetThreshold; bool smallNet = std::abs(simpleEval) > SmallNetThreshold;
bool psqtOnly = std::abs(simpleEval) > PsqtOnlyThreshold; bool psqtOnly = std::abs(simpleEval) > PsqtOnlyThreshold;
int nnueComplexity;
int nnueComplexity; int v;
Value nnue = smallNet ? networks.small.evaluate(pos, true, &nnueComplexity, psqtOnly) Value nnue = smallNet ? networks.small.evaluate(pos, true, &nnueComplexity, psqtOnly)
: networks.big.evaluate(pos, true, &nnueComplexity, false); : networks.big.evaluate(pos, true, &nnueComplexity, false);
// Blend optimism and eval with nnue complexity and material imbalance const auto adjustEval = [&](int optDiv, int nnueDiv, int pawnCountConstant, int pawnCountMul,
optimism += optimism * (nnueComplexity + std::abs(simpleEval - nnue)) / 524; int npmConstant, int evalDiv, int shufflingConstant,
nnue -= nnue * (nnueComplexity + std::abs(simpleEval - nnue)) / 31950; int shufflingDiv) {
// Blend optimism and eval with nnue complexity and material imbalance
optimism += optimism * (nnueComplexity + std::abs(simpleEval - nnue)) / optDiv;
nnue -= nnue * (nnueComplexity + std::abs(simpleEval - nnue)) / nnueDiv;
int npm = pos.non_pawn_material() / 64; int npm = pos.non_pawn_material() / 64;
int v = (nnue * (927 + npm + 9 * pos.count<PAWN>()) + optimism * (159 + npm)) / 1000; v = (nnue * (npm + pawnCountConstant + pawnCountMul * pos.count<PAWN>())
+ optimism * (npmConstant + npm))
/ evalDiv;
// Damp down the evaluation linearly when shuffling // Damp down the evaluation linearly when shuffling
int shuffling = pos.rule50_count(); int shuffling = pos.rule50_count();
v = v * (195 - shuffling) / 228; v = v * (shufflingConstant - shuffling) / shufflingDiv;
};
if (!smallNet)
adjustEval(513, 32395, 919, 11, 145, 1036, 178, 204);
else if (psqtOnly)
adjustEval(517, 32857, 908, 7, 155, 1019, 224, 238);
else
adjustEval(499, 32793, 903, 9, 147, 1067, 208, 211);
// Guarantee evaluation does not hit the tablebase range // Guarantee evaluation does not hit the tablebase range
v = std::clamp(v, VALUE_TB_LOSS_IN_MAX_PLY + 1, VALUE_TB_WIN_IN_MAX_PLY - 1); v = std::clamp(v, VALUE_TB_LOSS_IN_MAX_PLY + 1, VALUE_TB_WIN_IN_MAX_PLY - 1);

View File

@@ -29,7 +29,7 @@ class Position;
namespace Eval { namespace Eval {
constexpr inline int SmallNetThreshold = 1136, PsqtOnlyThreshold = 2656; constexpr inline int SmallNetThreshold = 1050, PsqtOnlyThreshold = 2500;
// The default net name MUST follow the format nn-[SHA256 first 12 digits].nnue // The default net name MUST follow the format nn-[SHA256 first 12 digits].nnue
// for the build process (profile-build and fishtest) to work. Do not change the // for the build process (profile-build and fishtest) to work. Do not change the