Skip to content

Commit f749496

Browse files
Stefano80snicolet
authored andcommitted
Reformat Eval::evaluate()
Non functional simplification: the goal of this patch is to make the style in the evaluate() function similar to the rest of the code. passed STC: LLR: 2.94 (-2.94,2.94) <-2.50,0.50> Total: 95608 W: 24058 L: 24026 D: 47524 Ptnml(0-2): 292, 10379, 26396, 10479, 258 https://tests.stockfishchess.org/tests/view/616c64fd99b580bf37797e4f closes #3744 Non-functional change
1 parent 8a74c08 commit f749496

File tree

1 file changed

+12
-23
lines changed

1 file changed

+12
-23
lines changed

src/evaluate.cpp

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,33 +1081,22 @@ Value Eval::evaluate(const Position& pos) {
10811081

10821082
Value v;
10831083

1084-
if (!useNNUE)
1085-
v = Evaluation<NO_TRACE>(pos).value();
1084+
// Deciding between classical and NNUE eval: for high PSQ imbalance we use classical,
1085+
// but we switch to NNUE during long shuffling or with high material on the board.
1086+
1087+
if ( !useNNUE
1088+
|| abs(eg_value(pos.psq_score())) * 5 > (850 + pos.non_pawn_material() / 64) * (5 + pos.rule50_count()))
1089+
v = Evaluation<NO_TRACE>(pos).value(); // classical
10861090
else
10871091
{
1088-
// Scale and shift NNUE for compatibility with search and classical evaluation
1089-
auto adjusted_NNUE = [&]()
1090-
{
1091-
int scale = 883
1092-
+ 32 * pos.count<PAWN>()
1093-
+ 32 * pos.non_pawn_material() / 1024;
1094-
1095-
Value nnue = NNUE::evaluate(pos, true) * scale / 1024;
1096-
1097-
if (pos.is_chess960())
1098-
nnue += fix_FRC(pos);
1099-
1100-
return nnue;
1101-
};
1092+
int scale = 883
1093+
+ 32 * pos.count<PAWN>()
1094+
+ 32 * pos.non_pawn_material() / 1024;
11021095

1103-
// If there is PSQ imbalance we use the classical eval, but we switch to
1104-
// NNUE eval faster when shuffling or if the material on the board is high.
1105-
int r50 = pos.rule50_count();
1106-
Value psq = Value(abs(eg_value(pos.psq_score())));
1107-
bool classical = psq * 5 > (850 + pos.non_pawn_material() / 64) * (5 + r50);
1096+
v = NNUE::evaluate(pos, true) * scale / 1024; // NNUE
11081097

1109-
v = classical ? Evaluation<NO_TRACE>(pos).value() // classical
1110-
: adjusted_NNUE(); // NNUE
1098+
if (pos.is_chess960())
1099+
v += fix_FRC(pos);
11111100
}
11121101

11131102
// Damp down the evaluation linearly when shuffling

0 commit comments

Comments
 (0)