Skip to content

Commit

Permalink
Eval
Browse files Browse the repository at this point in the history
  • Loading branch information
PikaCat-OuO committed Jul 7, 2024
1 parent f828304 commit dcc3386
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/evaluate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#include "nnue/nnue_accumulator.h"

namespace Stockfish {
int evaluate_52_0 = 372, evaluate_53_0 = 11013, evaluate_55_0 = 31, evaluate_56_0 = 576, evaluate_56_1 = 107, evaluate_56_2 = 535, evaluate_62_0 = 279;
TUNE(evaluate_52_0, evaluate_53_0, evaluate_55_0, evaluate_56_0, evaluate_56_1, evaluate_56_2, evaluate_62_0);

// Evaluate is the evaluator for the outer world. It returns a static evaluation
// of the position from the point of view of the side to move.
Expand All @@ -50,17 +52,17 @@ Value Eval::evaluate(const Eval::NNUE::Network& network,
int nnueComplexity = std::abs(psqt - positional);

// Blend optimism and eval with nnue complexity
optimism += optimism * nnueComplexity / 372;
nnue -= nnue * nnueComplexity / 11013;
optimism += optimism * nnueComplexity / (evaluate_52_0);
nnue -= nnue * nnueComplexity / (evaluate_53_0);

int mm = pos.major_material() / 31;
int v = (nnue * (576 + mm) + optimism * (107 + mm)) / 535;
int mm = pos.major_material() / (evaluate_55_0);
int v = (nnue * ((evaluate_56_0) + mm) + optimism * ((evaluate_56_1) + mm)) / (evaluate_56_2);

// Evaluation grain (to get more alpha-beta cuts) with randomization (for robustness)
v = (v / 16) * 16 - 1 + (pos.key() & 0x2);

// Damp down the evaluation linearly when shuffling
v -= (v * pos.rule60_count()) / 279;
v -= (v * pos.rule60_count()) / (evaluate_62_0);

// Guarantee evaluation does not hit the mate range
v = std::clamp(v, VALUE_MATED_IN_MAX_PLY + 1, VALUE_MATE_IN_MAX_PLY - 1);
Expand Down

0 comments on commit dcc3386

Please sign in to comment.