]> git.sesse.net Git - stockfish/blobdiff - src/evaluate.cpp
Adjust initiative in pure pawn endgames
[stockfish] / src / evaluate.cpp
index 56c975945d13d4713a7648db702446dfd6a8568a..6783ffd8595fcaa32f1e584ffdd2fca8362aeb41 100644 (file)
@@ -165,6 +165,7 @@ namespace {
   // Assorted bonuses and penalties
   const Score BishopPawns       = S(  8, 12);
   const Score CloseEnemies      = S(  7,  0);
+  const Score Connectivity      = S(  3,  1);
   const Score Hanging           = S( 52, 30);
   const Score HinderPassedPawn  = S(  8,  1);
   const Score KnightOnQueen     = S( 21, 11);
@@ -599,6 +600,10 @@ namespace {
         score += SliderOnQueen * popcount(b & safeThreats & attackedBy2[Us]);
     }
 
+    // Connectivity: ensure that knights, bishops, rooks, and queens are protected
+    b = (pos.pieces(Us) ^ pos.pieces(Us, PAWN, KING)) & attackedBy[Us][ALL_PIECES];
+    score += Connectivity * popcount(b);
+
     if (T)
         Trace::add(THREAT, Us, score);
 
@@ -760,6 +765,7 @@ namespace {
                     +  8 * pe->pawn_asymmetry()
                     + 12 * pos.count<PAWN>()
                     + 16 * pawnsOnBothFlanks
+                    + 48 * !pos.non_pawn_material()
                     -136 ;
 
     // Now apply the bonus: note that we find the attacking side by extracting