mirror of
https://github.com/opelly27/Stockfish.git
synced 2026-05-20 13:17:44 +00:00
Remove delta, adjusted, complexity from nnue code
...rather they're the consumer's concern whether to tweak the result or not. Passed STC: https://tests.stockfishchess.org/tests/view/665cea9ffd45fb0f907c53bd LLR: 2.93 (-2.94,2.94) <-1.75,0.25> Total: 69696 W: 18101 L: 17918 D: 33677 Ptnml(0-2): 195, 8171, 17929, 8362, 191 Passed LTC: https://tests.stockfishchess.org/tests/view/665cf761fd45fb0f907c5406 LLR: 2.96 (-2.94,2.94) <-1.75,0.25> Total: 63720 W: 16344 L: 16165 D: 31211 Ptnml(0-2): 32, 6990, 17625, 7193, 20 Non functional except for rounding issues of OutputScale changing bench. closes https://github.com/official-stockfish/Stockfish/pull/5344 Bench: 1378596
This commit is contained in:
+15
-8
@@ -24,8 +24,9 @@
|
||||
#include <cstdlib>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <tuple>
|
||||
|
||||
#include "nnue/network.h"
|
||||
#include "nnue/nnue_misc.h"
|
||||
@@ -60,17 +61,22 @@ Value Eval::evaluate(const Eval::NNUE::Networks& networks,
|
||||
|
||||
int simpleEval = simple_eval(pos, pos.side_to_move());
|
||||
bool smallNet = use_smallnet(pos);
|
||||
int nnueComplexity;
|
||||
int v;
|
||||
|
||||
Value nnue = smallNet ? networks.small.evaluate(pos, &caches.small, true, &nnueComplexity)
|
||||
: networks.big.evaluate(pos, &caches.big, true, &nnueComplexity);
|
||||
auto [psqt, positional] = smallNet ? networks.small.evaluate(pos, &caches.small)
|
||||
: networks.big.evaluate(pos, &caches.big);
|
||||
|
||||
constexpr int delta = 3;
|
||||
Value nnue = ((128 - delta) * psqt + (128 + delta) * positional) / 128;
|
||||
int nnueComplexity = std::abs(psqt - positional);
|
||||
|
||||
// Re-evaluate the position when higher eval accuracy is worth the time spent
|
||||
if (smallNet && (nnue * simpleEval < 0 || std::abs(nnue) < 250))
|
||||
{
|
||||
nnue = networks.big.evaluate(pos, &caches.big, true, &nnueComplexity);
|
||||
smallNet = false;
|
||||
std::tie(psqt, positional) = networks.big.evaluate(pos, &caches.big);
|
||||
nnue = ((128 - delta) * psqt + (128 + delta) * positional) / 128;
|
||||
nnueComplexity = std::abs(psqt - positional);
|
||||
smallNet = false;
|
||||
}
|
||||
|
||||
// Blend optimism and eval with nnue complexity
|
||||
@@ -108,8 +114,9 @@ std::string Eval::trace(Position& pos, const Eval::NNUE::Networks& networks) {
|
||||
|
||||
ss << std::showpoint << std::showpos << std::fixed << std::setprecision(2) << std::setw(15);
|
||||
|
||||
Value v = networks.big.evaluate(pos, &caches->big, false);
|
||||
v = pos.side_to_move() == WHITE ? v : -v;
|
||||
auto [psqt, positional] = networks.big.evaluate(pos, &caches->big);
|
||||
Value v = psqt + positional;
|
||||
v = pos.side_to_move() == WHITE ? v : -v;
|
||||
ss << "NNUE evaluation " << 0.01 * UCIEngine::to_cp(v, pos) << " (white side)\n";
|
||||
|
||||
v = evaluate(networks, pos, *caches, VALUE_ZERO);
|
||||
|
||||
Reference in New Issue
Block a user