1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-05-01 09:13:08 +00:00

Avoid calculating nnue complexity twice

Passed non-regression STC:
https://tests.stockfishchess.org/tests/view/6697459d4ff211be9d4ec236
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 146848 W: 38289 L: 38189 D: 70370
Ptnml(0-2): 503, 16665, 39046, 16649, 561

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

No functional change
This commit is contained in:
Linmiao Xu 2024-07-17 00:15:44 -04:00 committed by Joost VandeVondele
parent c8d8e362fc
commit c2837769e0

View file

@ -67,18 +67,17 @@ Value Eval::evaluate(const Eval::NNUE::Networks& networks,
: networks.big.evaluate(pos, &caches.big); : networks.big.evaluate(pos, &caches.big);
Value nnue = (125 * psqt + 131 * positional) / 128; Value nnue = (125 * psqt + 131 * positional) / 128;
int nnueComplexity = std::abs(psqt - positional);
// Re-evaluate the position when higher eval accuracy is worth the time spent // Re-evaluate the position when higher eval accuracy is worth the time spent
if (smallNet && (nnue * simpleEval < 0 || std::abs(nnue) < 227)) if (smallNet && (nnue * simpleEval < 0 || std::abs(nnue) < 227))
{ {
std::tie(psqt, positional) = networks.big.evaluate(pos, &caches.big); std::tie(psqt, positional) = networks.big.evaluate(pos, &caches.big);
nnue = (125 * psqt + 131 * positional) / 128; nnue = (125 * psqt + 131 * positional) / 128;
nnueComplexity = std::abs(psqt - positional);
smallNet = false; smallNet = false;
} }
// Blend optimism and eval with nnue complexity // Blend optimism and eval with nnue complexity
int nnueComplexity = std::abs(psqt - positional);
optimism += optimism * nnueComplexity / (smallNet ? 433 : 453); optimism += optimism * nnueComplexity / (smallNet ? 433 : 453);
nnue -= nnue * nnueComplexity / (smallNet ? 18815 : 17864); nnue -= nnue * nnueComplexity / (smallNet ? 18815 : 17864);