Skip to content

Commit

Permalink
Simplify non-pawn material divisor to a constant
Browse files Browse the repository at this point in the history
Passed STC:
https://tests.stockfishchess.org/tests/view/662942603fe04ce4cefc7aba
LLR: 2.93 (-2.94,2.94) <-1.75,0.25>
Total: 272832 W: 70456 L: 70497 D: 131879
Ptnml(0-2): 1020, 32619, 69154, 32628, 995

Passed LTC:
https://tests.stockfishchess.org/tests/view/662dfe3b6115ff6764c829eb
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 100254 W: 25446 L: 25303 D: 49505
Ptnml(0-2): 121, 11292, 27166, 11419, 129

closes official-stockfish#5198

Bench: 1544645
  • Loading branch information
locutus2 authored and Disservin committed Apr 28, 2024
1 parent 834e8ff commit 48a3b7c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/evaluate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ Value Eval::evaluate(const Eval::NNUE::Networks& networks,
? networks.small.evaluate(pos, &caches.small, true, &nnueComplexity, psqtOnly)
: networks.big.evaluate(pos, &caches.big, true, &nnueComplexity, false);

const auto adjustEval = [&](int optDiv, int nnueDiv, int npmDiv, int pawnCountConstant,
int pawnCountMul, int npmConstant, int evalDiv,
int shufflingConstant, int shufflingDiv) {
const auto adjustEval = [&](int optDiv, int nnueDiv, int pawnCountConstant, int pawnCountMul,
int npmConstant, int evalDiv, int shufflingConstant,
int shufflingDiv) {
// Blend optimism and eval with nnue complexity and material imbalance
optimism += optimism * (nnueComplexity + std::abs(simpleEval - nnue)) / optDiv;
nnue -= nnue * (nnueComplexity * 5 / 3) / nnueDiv;

int npm = pos.non_pawn_material() / npmDiv;
int npm = pos.non_pawn_material() / 64;
v = (nnue * (npm + pawnCountConstant + pawnCountMul * pos.count<PAWN>())
+ optimism * (npmConstant + npm))
/ evalDiv;
Expand All @@ -82,11 +82,11 @@ Value Eval::evaluate(const Eval::NNUE::Networks& networks,
};

if (!smallNet)
adjustEval(524, 32395, 66, 942, 11, 139, 1058, 178, 204);
adjustEval(524, 32395, 942, 11, 139, 1058, 178, 204);
else if (psqtOnly)
adjustEval(517, 32857, 65, 908, 7, 155, 1006, 224, 238);
adjustEval(517, 32857, 908, 7, 155, 1006, 224, 238);
else
adjustEval(515, 32793, 63, 944, 9, 140, 1067, 206, 206);
adjustEval(515, 32793, 944, 9, 140, 1067, 206, 206);

// 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);
Expand Down

0 comments on commit 48a3b7c

Please sign in to comment.