]> git.sesse.net Git - stockfish/commitdiff
Endgame malus for having a king in a pawnless flank
authorStéphane Nicolet <cassio@free.fr>
Mon, 24 Oct 2016 20:09:09 +0000 (22:09 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Tue, 25 Oct 2016 04:57:29 +0000 (06:57 +0200)
Original idea by "ElbertoOne", while "FauziAkram" suggested to put a
small midgame penalty too.

STC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 71808 W: 13038 L: 12610 D: 46160

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 150874 W: 19828 L: 19221 D: 111825

Bench: 6077005

src/evaluate.cpp

index d1799d6064810e3d58e6d8a380740d9504377f93..c37bd26f9c32b81c8da16692ddb5a40a480be4ee 100644 (file)
@@ -198,6 +198,7 @@ namespace {
   const Score Hanging             = S(48, 27);
   const Score ThreatByPawnPush    = S(38, 22);
   const Score Unstoppable         = S( 0, 20);
+  const Score PawnlessFlank       = S(20, 80);
 
   // Penalty for a bishop on a1/h1 (a8/h8 for black) which is trapped by
   // a friendly pawn on b2/g2 (b7/g7 for black). This can obviously only
@@ -482,7 +483,8 @@ namespace {
     }
 
     // King tropism: firstly, find squares that opponent attacks in our king flank
-    b = ei.attackedBy[Them][ALL_PIECES] & KingFlank[Us][file_of(ksq)];
+    File kf = file_of(ksq);
+    b = ei.attackedBy[Them][ALL_PIECES] & KingFlank[Us][kf];
 
     assert(((Us == WHITE ? b << 4 : b >> 4) & b) == 0);
     assert(popcount(Us == WHITE ? b << 4 : b >> 4) == popcount(b));
@@ -494,6 +496,10 @@ namespace {
 
     score -= CloseEnemies * popcount(b);
 
+    // Penalty when our king is on a pawnless flank
+    if (!(pos.pieces(PAWN) & (KingFlank[WHITE][kf] | KingFlank[BLACK][kf])))
+        score -= PawnlessFlank;
+
     if (DoTrace)
         Trace::add(KING, Us, score);