]> git.sesse.net Git - stockfish/blobdiff - src/evaluate.cpp
King safety parameters improved
[stockfish] / src / evaluate.cpp
index 3d9c44324405f77afd200bda162e41e779e3133d..f13ddf25315d9419520011ad60d339a5eee103e4 100644 (file)
@@ -211,10 +211,10 @@ namespace {
   const int KingAttackWeights[PIECE_TYPE_NB] = { 0, 0, 78, 56, 45, 11 };
 
   // Penalties for enemy's safe checks
-  const int QueenCheck        = 745;
-  const int RookCheck         = 688;
-  const int BishopCheck       = 588;
-  const int KnightCheck       = 924;
+  const int QueenCheck        = 810;
+  const int RookCheck         = 888;
+  const int BishopCheck       = 400;
+  const int KnightCheck       = 790;
 
   // Threshold for lazy evaluation
   const Value LazyThreshold = Value(1500);
@@ -423,12 +423,12 @@ namespace {
         // number and types of the enemy's attacking pieces, the number of
         // attacked and undefended squares around our king and the quality of
         // the pawn shelter (current 'score' value).
-        kingDanger =  std::min(807, ei.kingAttackersCount[Them] * ei.kingAttackersWeight[Them])
-                    + 101 * ei.kingAdjacentZoneAttacksCount[Them]
-                    + 235 * popcount(undefended)
-                    + 134 * (popcount(b) + !!pos.pinned_pieces(Us))
-                    - 717 * !pos.count<QUEEN>(Them)
-                    -   7 * mg_value(score) / 5 - 5;
+        kingDanger =  std::min(820, ei.kingAttackersCount[Them] * ei.kingAttackersWeight[Them])
+                    + 103 * ei.kingAdjacentZoneAttacksCount[Them]
+                    + 190 * popcount(undefended)
+                    + 142 * (popcount(b) + !!pos.pinned_pieces(Us))
+                    - 810 * !pos.count<QUEEN>(Them)
+                    -   6 * mg_value(score) / 5 - 5;
 
         // Analyse the safe enemy's checks which are possible on next move
         safe  = ~pos.pieces(Them);
@@ -477,7 +477,7 @@ namespace {
 
         // Transform the kingDanger units into a Score, and substract it from the evaluation
         if (kingDanger > 0)
-            score -= make_score(std::min(kingDanger * kingDanger / 4096,  2 * int(BishopValueMg)), 0);
+            score -= make_score(kingDanger * kingDanger / 4096, 0);
     }
 
     // King tropism: firstly, find squares that opponent attacks in our king flank
@@ -720,10 +720,9 @@ namespace {
 
     // ...count safe + (behind & safe) with a single popcount.
     int bonus = popcount((Us == WHITE ? safe << 32 : safe >> 32) | (behind & safe));
-    bonus = std::min(16, bonus);
     int weight = pos.count<ALL_PIECES>(Us) - 2 * ei.pe->open_files();
 
-    return make_score(bonus * weight * weight / 18, 0);
+    return make_score(bonus * weight * weight / 16, 0);
   }