mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-23 10:36:26 +08:00
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:
@@ -52,22 +52,35 @@ Value Eval::evaluate(const Eval::NNUE::Networks& networks, const Position& pos,
|
||||
int simpleEval = simple_eval(pos, pos.side_to_move());
|
||||
bool smallNet = std::abs(simpleEval) > SmallNetThreshold;
|
||||
bool psqtOnly = std::abs(simpleEval) > PsqtOnlyThreshold;
|
||||
|
||||
int nnueComplexity;
|
||||
int nnueComplexity;
|
||||
int v;
|
||||
|
||||
Value nnue = smallNet ? networks.small.evaluate(pos, true, &nnueComplexity, psqtOnly)
|
||||
: networks.big.evaluate(pos, true, &nnueComplexity, false);
|
||||
|
||||
// Blend optimism and eval with nnue complexity and material imbalance
|
||||
optimism += optimism * (nnueComplexity + std::abs(simpleEval - nnue)) / 524;
|
||||
nnue -= nnue * (nnueComplexity + std::abs(simpleEval - nnue)) / 31950;
|
||||
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 + std::abs(simpleEval - nnue)) / nnueDiv;
|
||||
|
||||
int npm = pos.non_pawn_material() / 64;
|
||||
int v = (nnue * (927 + npm + 9 * pos.count<PAWN>()) + optimism * (159 + npm)) / 1000;
|
||||
int npm = pos.non_pawn_material() / 64;
|
||||
v = (nnue * (npm + pawnCountConstant + pawnCountMul * pos.count<PAWN>())
|
||||
+ optimism * (npmConstant + npm))
|
||||
/ evalDiv;
|
||||
|
||||
// Damp down the evaluation linearly when shuffling
|
||||
int shuffling = pos.rule50_count();
|
||||
v = v * (195 - shuffling) / 228;
|
||||
// Damp down the evaluation linearly when shuffling
|
||||
int shuffling = pos.rule50_count();
|
||||
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
|
||||
v = std::clamp(v, VALUE_TB_LOSS_IN_MAX_PLY + 1, VALUE_TB_WIN_IN_MAX_PLY - 1);
|
||||
|
||||
@@ -29,7 +29,7 @@ class Position;
|
||||
|
||||
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
|
||||
// for the build process (profile-build and fishtest) to work. Do not change the
|
||||
|
||||
Reference in New Issue
Block a user