Add min pawn-king distance to endgame evaluation
[stockfish] / src / pawns.cpp
index f71e2a3970f8cbd520e8567ec7d6729126b05eb8..73a9b904b347757fda1ba601344dfd69f913259b 100644 (file)
@@ -268,7 +268,7 @@ Score PawnEntry::update_safety(const Position& pos, Square ksq) {
       while (!(DistanceRingsBB[ksq][minKPdistance[Us]++] & pawns)) {}
 
   if (relative_rank(Us, ksq) > RANK_4)
-      return kingSafety[Us] = SCORE_ZERO;
+      return kingSafety[Us] = make_score(0, -16 * minKPdistance[Us]);
 
   Value bonus = shelter_storm<Us>(pos, ksq);
 
@@ -279,7 +279,7 @@ Score PawnEntry::update_safety(const Position& pos, Square ksq) {
   if (pos.can_castle(make_castle_right(Us, QUEEN_SIDE)))
       bonus = std::max(bonus, shelter_storm<Us>(pos, relative_square(Us, SQ_C1)));
 
-  return kingSafety[Us] = make_score(bonus, 0);
+  return kingSafety[Us] = make_score(bonus, -16 * minKPdistance[Us]);
 }
 
 // Explicit template instantiation