]> git.sesse.net Git - stockfish/blobdiff - src/nnue/evaluate_nnue.cpp
Blend nnue complexity with classical.
[stockfish] / src / nnue / evaluate_nnue.cpp
index 9ee599f4aa40e2ecef8a046d8f90e6055540386d..eb6ad71f8d95cb86e5759066d026b183624432b0 100644 (file)
@@ -137,7 +137,7 @@ namespace Stockfish::Eval::NNUE {
   }
 
   // Evaluation function. Perform differential calculation.
-  Value evaluate(const Position& pos, bool adjusted) {
+  Value evaluate(const Position& pos, bool adjusted, int* complexity) {
 
     // We manually align the arrays on the stack because with gcc < 9.3
     // overaligning stack variables with alignas() doesn't work correctly.
@@ -161,9 +161,12 @@ namespace Stockfish::Eval::NNUE {
     const auto psqt = featureTransformer->transform(pos, transformedFeatures, bucket);
     const auto positional = network[bucket]->propagate(transformedFeatures);
 
+    if (complexity)
+        *complexity = abs(psqt - positional) / OutputScale;
+
     // Give more value to positional evaluation when adjusted flag is set
     if (adjusted)
-        return static_cast<Value>(((128 - delta) * psqt + (128 + delta) * positional) / 128 / OutputScale);
+        return static_cast<Value>(((128 - delta) * psqt + (128 + delta) * positional) / (128 * OutputScale));
     else
         return static_cast<Value>((psqt + positional) / OutputScale);
   }