Reintroduce the old "trapped bishop in the corner" evaluation term
authorTord Romstad <tord@cm-84.215.83.169.getinternet.no>
Mon, 3 Jan 2011 21:32:57 +0000 (22:32 +0100)
committerTord Romstad <tord@cm-84.215.83.169.getinternet.no>
Mon, 3 Jan 2011 21:32:57 +0000 (22:32 +0100)
for Chess960 games.

After 1918 games at 30"
Mod - Orig: 1052-866 (+532,-346,=1040), Elo +33.8

src/evaluate.cpp

index 2a80568d50ef77e520d6a7e2f4c053393a9152d2..58feae39c470b57406c1305c4c43d3ddc9e593b1 100644 (file)
@@ -168,6 +168,11 @@ namespace {
   // right to castle.
   const Value TrappedRookPenalty = Value(180);
 
+  // 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
+  // happen in Chess960 games.
+  const Score TrappedBishopA1H1Penalty = make_score(100, 100);
+
   // The SpaceMask[Color] contains the area of the board which is considered
   // by the space evaluation. In the middle game, each side is given a bonus
   // based on how many squares inside this area are safe and available for
@@ -556,6 +561,28 @@ namespace {
             bonus += (Piece == ROOK ? RookOn7thBonus : QueenOn7thBonus);
         }
 
+        // Special extra evaluation for bishops
+        if (Piece == BISHOP)
+        {
+            // An important Chess960 pattern: A cornered bishop blocked by
+            // a friendly pawn diagonally in front of it is a very serious
+            // problem, especially when that pawn is also blocked.
+            if (s == relative_square(Us, SQ_A1) || s == relative_square(Us, SQ_H1))
+            {
+                SquareDelta d = pawn_push(Us) 
+                   + (square_file(s) == FILE_A ? DELTA_E : DELTA_W);
+                if (pos.piece_on(s + d) == piece_of_color_and_type(Us, PAWN))
+                {
+                    if (!pos.square_is_empty(s + d + pawn_push(Us)))
+                        bonus -= 2*TrappedBishopA1H1Penalty;
+                    else if (pos.piece_on(s + 2*d) == piece_of_color_and_type(Us, PAWN))
+                        bonus -= TrappedBishopA1H1Penalty;
+                    else
+                        bonus -= TrappedBishopA1H1Penalty / 2;
+                }
+            }
+        }
+
         // Special extra evaluation for rooks
         if (Piece == ROOK)
         {