]> git.sesse.net Git - stockfish/blobdiff - src/evaluate.cpp
Fix compilation after recent merge.
[stockfish] / src / evaluate.cpp
index 00498bf02f02455dff77e4c483f87ec71e6b0ee4..586cadc0ec50c6cb5fe211aaecd7ad1efa755afc 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <algorithm>
 #include <cassert>
+#include <cmath>
 #include <cstdlib>
 #include <fstream>
 #include <iomanip>
@@ -57,14 +58,13 @@ namespace Eval {
 
 std::string currentEvalFileName = "None";
 
-// NNUE::init() tries to load a NNUE network at startup time, or when the engine
+// Tries to load a NNUE network at startup time, or when the engine
 // receives a UCI command "setoption name EvalFile value nn-[a-z0-9]{12}.nnue"
 // The name of the NNUE network is always retrieved from the EvalFile option.
 // We search the given network in three locations: internally (the default
 // network may be embedded in the binary), in the active working directory and
 // in the engine directory. Distro packagers may define the DEFAULT_NNUE_DIRECTORY
 // variable to have the engine search in a special directory in their distro.
-
 void NNUE::init() {
 
     std::string eval_file = std::string(Options["EvalFile"]);
@@ -111,7 +111,7 @@ void NNUE::init() {
         }
 }
 
-// NNUE::verify() verifies that the last net used was loaded successfully
+// Verifies that the last net used was loaded successfully
 void NNUE::verify() {
 
     std::string eval_file = std::string(Options["EvalFile"]);
@@ -124,11 +124,11 @@ void NNUE::verify() {
         std::string msg1 =
           "Network evaluation parameters compatible with the engine must be available.";
         std::string msg2 = "The network file " + eval_file + " was not loaded successfully.";
-        std::string msg3 =
-          "The UCI option EvalFile might need to specify the full path, including the directory name, to the network file.";
-        std::string msg4 =
-          "The default net can be downloaded from: https://tests.stockfishchess.org/api/nn/"
-          + std::string(EvalFileDefaultName);
+        std::string msg3 = "The UCI option EvalFile might need to specify the full path, "
+                           "including the directory name, to the network file.";
+        std::string msg4 = "The default net can be downloaded from: "
+                           "https://tests.stockfishchess.org/api/nn/"
+                         + std::string(EvalFileDefaultName);
         std::string msg5 = "The engine will be terminated now.";
 
         sync_cout << "info string ERROR: " << msg1 << sync_endl;
@@ -145,19 +145,17 @@ void NNUE::verify() {
 }
 
 
-// simple_eval() returns a static, purely materialistic evaluation of the position
-// from the point of view of the given color. It can be divided by PawnValue to get
+// Returns a static, purely materialistic evaluation of the position from
+// the point of view of the given color. It can be divided by PawnValue to get
 // an approximation of the material advantage on the board in terms of pawns.
-
 Value Eval::simple_eval(const Position& pos, Color c) {
     return PawnValue * (pos.count<PAWN>(c) - pos.count<PAWN>(~c))
          + (pos.non_pawn_material(c) - pos.non_pawn_material(~c));
 }
 
 
-// evaluate() is the evaluator for the outer world. It returns a static evaluation
+// 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.
-
 Value Eval::evaluate(const Position& pos) {
 
     assert(!pos.checkers());
@@ -167,9 +165,9 @@ Value Eval::evaluate(const Position& pos) {
     int   shuffling  = pos.rule50_count();
     int   simpleEval = simple_eval(pos, stm) + (int(pos.key() & 7) - 3);
 
-    bool lazy = abs(simpleEval) >= RookValue + KnightValue + 16 * shuffling * shuffling
-                                     abs(pos.this_thread()->bestValue)
-                                     abs(pos.this_thread()->rootSimpleEval);
+    bool lazy = std::abs(simpleEval) >= RookValue + KnightValue + 16 * shuffling * shuffling
+                                          + std::abs(pos.this_thread()->bestValue)
+                                          + std::abs(pos.this_thread()->rootSimpleEval);
 
     if (lazy)
         v = Value(simpleEval);
@@ -181,8 +179,8 @@ Value Eval::evaluate(const Position& pos) {
         Value optimism = pos.this_thread()->optimism[stm];
 
         // Blend optimism and eval with nnue complexity and material imbalance
-        optimism += optimism * (nnueComplexity + abs(simpleEval - nnue)) / 512;
-        nnue -= nnue * (nnueComplexity + abs(simpleEval - nnue)) / 32768;
+        optimism += optimism * (nnueComplexity + std::abs(simpleEval - nnue)) / 512;
+        nnue -= nnue * (nnueComplexity + std::abs(simpleEval - nnue)) / 32768;
 
         int npm = pos.non_pawn_material() / 64;
         v       = (nnue * (915 + npm + 9 * pos.count<PAWN>()) + optimism * (154 + npm)) / 1024;
@@ -197,11 +195,10 @@ Value Eval::evaluate(const Position& pos) {
     return v;
 }
 
-// trace() is like evaluate(), but instead of returning a value, it returns
+// Like evaluate(), but instead of returning a value, it returns
 // a string (suitable for outputting to stdout) that contains the detailed
 // descriptions and values of each evaluation term. Useful for debugging.
 // Trace scores are from white's point of view
-
 std::string Eval::trace(Position& pos) {
 
     if (pos.checkers())