]> git.sesse.net Git - stockfish/blobdiff - src/evaluate.cpp
Double king safety weights
[stockfish] / src / evaluate.cpp
index 7844deb6ae27290333531b91ae220986096f4009..49620e4666d74b642328784074fa6a6cf819d2af 100644 (file)
@@ -200,12 +200,12 @@ namespace {
   const int KingAttackWeights[] = { 0, 0, 2, 2, 3, 5 };
 
   // Bonuses for enemy's safe checks
-  const int QueenContactCheck = 6;
-  const int RookContactCheck  = 4;
-  const int QueenCheck        = 3;
-  const int RookCheck         = 2;
+  const int QueenContactCheck = 12;
+  const int RookContactCheck  = 8;
+  const int QueenCheck        = 6;
+  const int RookCheck         = 4;
   const int BishopCheck       = 1;
-  const int KnightCheck       = 1;
+  const int KnightCheck       = 2;
 
   // KingExposed[Square] contains penalties based on the position of the
   // defending king, indexed by king's square (from white's point of view).
@@ -499,7 +499,7 @@ Value do_evaluate(const Position& pos, Value& margin) {
 
         if (b & ei.kingRing[Them])
         {
-            ei.kingAttackersCount[Us]++;
+            ++ei.kingAttackersCount[Us];
             ei.kingAttackersWeight[Us] += KingAttackWeights[Piece];
             Bitboard bb = (b & ei.attackedBy[Them][KING]);
             if (bb)
@@ -583,9 +583,9 @@ Value do_evaluate(const Position& pos, Value& margin) {
             const enum Piece P = make_piece(Us, PAWN);
             Square d = pawn_push(Us) + (file_of(s) == FILE_A ? DELTA_E : DELTA_W);
             if (pos.piece_on(s + d) == P)
-                score -= !pos.is_empty(s + d + pawn_push(Us)) ? TrappedBishopA1H1 * 4
-                        : pos.piece_on(s + d + d) == P        ? TrappedBishopA1H1 * 2
-                                                              : TrappedBishopA1H1;
+                score -= !pos.empty(s + d + pawn_push(Us)) ? TrappedBishopA1H1 * 4
+                        : pos.piece_on(s + d + d) == P     ? TrappedBishopA1H1 * 2
+                                                           : TrappedBishopA1H1;
         }
     }
 
@@ -699,7 +699,7 @@ Value do_evaluate(const Position& pos, Value& margin) {
         // number and types of the enemy's attacking pieces, the number of
         // attacked and undefended squares around our king, the square of the
         // king, and the quality of the pawn shelter.
-        attackUnits =  std::min(25, (ei.kingAttackersCount[Them] * ei.kingAttackersWeight[Them]) / 2)
+        attackUnits =  std::min(20, (ei.kingAttackersCount[Them] * ei.kingAttackersWeight[Them]) / 2)
                      + 3 * (ei.kingAdjacentZoneAttacksCount[Them] + popcount<Max15>(undefended))
                      + KingExposed[relative_square(Us, ksq)]
                      - mg_value(score) / 32;
@@ -797,7 +797,7 @@ Value do_evaluate(const Position& pos, Value& margin) {
     {
         Square s = pop_lsb(&b);
 
-        assert(pos.pawn_is_passed(Us, s));
+        assert(pos.pawn_passed(Us, s));
 
         int r = int(relative_rank(Us, s) - RANK_2);
         int rr = r * (r - 1);
@@ -819,7 +819,7 @@ Value do_evaluate(const Position& pos, Value& margin) {
                 ebonus -= Value(square_distance(pos.king_square(Us), blockSq + pawn_push(Us)) * rr);
 
             // If the pawn is free to advance, increase bonus
-            if (pos.is_empty(blockSq))
+            if (pos.empty(blockSq))
             {
                 squaresToQueen = forward_bb(Us, s);
 
@@ -906,7 +906,7 @@ Value do_evaluate(const Position& pos, Value& margin) {
     if (!b || pos.non_pawn_material(~us))
         return SCORE_ZERO;
 
-    return Unstoppable * int(relative_rank(WHITE, frontmost_sq(us, b)));
+    return Unstoppable * int(relative_rank(us, frontmost_sq(us, b)));
   }