]> git.sesse.net Git - stockfish/blobdiff - src/evaluate.cpp
Simplify material difference in evaluate
[stockfish] / src / evaluate.cpp
index 7f0ea4bc6040c4d38d0958fe0b3e61eeafe5a5de..728990680f6a1ac9e6fdd8df0e88a29ee327c7b3 100644 (file)
@@ -143,7 +143,6 @@ Value Eval::evaluate(const Position& pos) {
   assert(!pos.checkers());
 
   Value v;
-  Value psq = pos.psq_eg_stm();
 
   int nnueComplexity;
   int npm = pos.non_pawn_material() / 64;
@@ -153,8 +152,11 @@ Value Eval::evaluate(const Position& pos) {
 
   Value nnue = NNUE::evaluate(pos, true, &nnueComplexity);
 
+  int material =  pos.non_pawn_material(stm) - pos.non_pawn_material(~stm)
+                + 126 * (pos.count<PAWN>(stm) - pos.count<PAWN>(~stm));
+
   // Blend optimism with nnue complexity and (semi)classical complexity
-  optimism += optimism * (nnueComplexity + abs(psq - nnue)) / 512;
+  optimism += optimism * (nnueComplexity + abs(material - nnue)) / 512;
 
   v = (  nnue     * (915 + npm + 9 * pos.count<PAWN>())
        + optimism * (154 + npm +     pos.count<PAWN>())) / 1024;