]> git.sesse.net Git - stockfish/blobdiff - src/evaluate.cpp
Introduce scale factor in pawn evaluation
[stockfish] / src / evaluate.cpp
index 3680dd36fc30131867bfac8f588bd0ce30731636..5f86227c2c5e9718e4ec76a967638167054ebff0 100644 (file)
@@ -430,6 +430,13 @@ Value do_evaluate(const Position& pos, EvalInfo& ei, int threadID) {
           factor[BLACK] = sf;
   }
 
+  // If we don't already have an unusual scale factor, use pawn
+  // evaluation ones.
+  if (factor[WHITE] == SCALE_FACTOR_NORMAL)
+      factor[WHITE] = ei.pi->scale_factor(WHITE);
+  if (factor[BLACK] == SCALE_FACTOR_NORMAL)
+      factor[BLACK] = ei.pi->scale_factor(BLACK);
+
   // Interpolate between the middle game and the endgame score
   Color stm = pos.side_to_move();
 
@@ -870,7 +877,7 @@ namespace {
   }
 
 
-  // evaluate_passed_pawns() evaluates the passed pawns of the given color
+  // evaluate_passed_pawns_of_color() evaluates the passed pawns of the given color
 
   template<Color Us>
   void evaluate_passed_pawns_of_color(const Position& pos, int movesToGo[], Square pawnToGo[], EvalInfo& ei) {
@@ -961,7 +968,7 @@ namespace {
             qsq = relative_square(Us, make_square(square_file(s), RANK_8));
             d =  square_distance(s, qsq)
                - square_distance(theirKingSq, qsq)
-               + (Us != pos.side_to_move());
+               + int(Us != pos.side_to_move());
 
             if (d < 0)
             {
@@ -1217,11 +1224,10 @@ namespace {
             SafetyTable[i] = Value((int)(a * (i - b) * (i - b)));
     }
 
-    for (int i = 0; i < 100; i++)
+    for (int i = 1; i < 100; i++)
     {
-        if (SafetyTable[i+1] - SafetyTable[i] > maxSlope)
-            for (int j = i + 1; j < 100; j++)
-                SafetyTable[j] = SafetyTable[j-1] + Value(maxSlope);
+        if (SafetyTable[i] - SafetyTable[i - 1] > maxSlope)
+            SafetyTable[i] = SafetyTable[i - 1] + Value(maxSlope);
 
         if (SafetyTable[i]  > Value(peak))
             SafetyTable[i] = Value(peak);