]> git.sesse.net Git - stockfish/blobdiff - src/evaluate.cpp
Avoid double function dispatch
[stockfish] / src / evaluate.cpp
index 0153fa95a41c613cba09a4ff5521dc834da5227d..64760d4da5d206f7efc4ac6535fb0b0266cf261a 100644 (file)
@@ -148,10 +148,6 @@ namespace {
 
   #undef S
 
-  // Threats weights indexed by sente (side to move has a bigger weight)
-  const int ConcurrentThreatsWeight[2] = { 3, 15 };
-  const int ThreatsWeight[2] = { 249, 267 };
-
   // Bonus for unstoppable passed pawns
   const Value UnstoppablePawnValue = Value(0x500);
 
@@ -640,8 +636,6 @@ namespace {
     const Color Them = (Us == WHITE ? BLACK : WHITE);
 
     Bitboard b;
-    Value mg, eg;
-    int sente, threatCount = 0;
     Score bonus = make_score(0, 0);
 
     // Enemy pieces not defended by a pawn and under our attack
@@ -660,20 +654,9 @@ namespace {
         if (b)
             for (PieceType pt2 = PAWN; pt2 < KING; pt2++)
                 if (b & pos.pieces(pt2))
-                {
                     bonus += ThreatBonus[pt1][pt2];
-                    threatCount++;
-                }
     }
-
-    sente = (Us == pos.side_to_move());
-
-    // Non linear threat evaluation. Increase threats score according to the
-    // number of concurrent threats and to the side to move.
-    mg = (mg_value(bonus) + mg_value(bonus) * ConcurrentThreatsWeight[sente] * threatCount / 256) * ThreatsWeight[sente] / 256;
-    eg = (eg_value(bonus) + eg_value(bonus) * ConcurrentThreatsWeight[sente] * threatCount / 256) * ThreatsWeight[sente] / 256;
-
-    ei.value += Sign[Us] * make_score(mg, eg);
+    ei.value += Sign[Us] * bonus;
   }
 
 
@@ -812,7 +795,6 @@ namespace {
     {
         Square s = pop_1st_bit(&b);
 
-        assert(pos.piece_on(s) == piece_of_color_and_type(Us, PAWN));
         assert(pos.pawn_is_passed(Us, s));
 
         int r = int(relative_rank(Us, s) - RANK_2);
@@ -914,6 +896,7 @@ namespace {
             Square s = pop_1st_bit(&b);
             Square queeningSquare = relative_square(c, make_square(square_file(s), RANK_8));
             int d =  square_distance(s, queeningSquare)
+                   - (relative_rank(c, s) == RANK_2) // Double pawn push
                    - square_distance(pos.king_square(opposite_color(c)), queeningSquare)
                    + int(c != pos.side_to_move());