]> git.sesse.net Git - stockfish/blobdiff - src/evaluate.cpp
MobilityArea (simplified)
[stockfish] / src / evaluate.cpp
index f2c5cf7f7488cf1b5cca75cca41bbe4bbdb894d1..37cdce997c8ec014484c5ab865d50c89751a4d62 100644 (file)
@@ -124,8 +124,12 @@ namespace {
       S( 94, 99), S( 96,100), S(99,111), S(99,112) }
   };
 
       S( 94, 99), S( 96,100), S(99,111), S(99,112) }
   };
 
-  // Outpost[knight/bishop][supported by pawn]
-  const Score Outpost[2][2] = {{S(28,7), S(42,11)}, {S(12,3), S(18,5)}};
+  // Outpost[knight/bishop][supported by pawn] contains bonuses for knights and bishops
+  // outposts, bigger if outpost piece is supported by a pawn.
+  const Score Outpost[][2] = {
+    { S(28, 7), S(42,11) }, // Knights
+    { S(12, 3), S(18, 5) }  // Bishops
+  };
 
   // Threat[defended/weak][minor/major attacking][attacked PieceType] contains
   // bonuses according to which piece type attacks which one.
 
   // Threat[defended/weak][minor/major attacking][attacked PieceType] contains
   // bonuses according to which piece type attacks which one.
@@ -697,9 +701,18 @@ namespace {
     ei.attackedBy[WHITE][ALL_PIECES] |= ei.attackedBy[WHITE][KING];
     ei.attackedBy[BLACK][ALL_PIECES] |= ei.attackedBy[BLACK][KING];
 
     ei.attackedBy[WHITE][ALL_PIECES] |= ei.attackedBy[WHITE][KING];
     ei.attackedBy[BLACK][ALL_PIECES] |= ei.attackedBy[BLACK][KING];
 
-    // Do not include in mobility squares protected by enemy pawns or occupied by our pawns or king
-    Bitboard mobilityArea[] = { ~(ei.attackedBy[BLACK][PAWN] | pos.pieces(WHITE, PAWN, KING)),
-                                ~(ei.attackedBy[WHITE][PAWN] | pos.pieces(BLACK, PAWN, KING)) };
+    // Pawns blocked or on ranks 2 and 3. Will be excluded from the mobility area
+    Bitboard blockedPawns[] = {
+      pos.pieces(WHITE, PAWN) & (shift_bb<DELTA_S>(pos.pieces()) | Rank2BB | Rank3BB),
+      pos.pieces(BLACK, PAWN) & (shift_bb<DELTA_N>(pos.pieces()) | Rank7BB | Rank6BB)
+    };
+
+    // Do not include in mobility squares protected by enemy pawns, or occupied
+    // by our blocked pawns or king.
+    Bitboard mobilityArea[] = {
+      ~(ei.attackedBy[BLACK][PAWN] | blockedPawns[WHITE] | pos.king_square(WHITE)),
+      ~(ei.attackedBy[WHITE][PAWN] | blockedPawns[BLACK] | pos.king_square(BLACK))
+    };
 
     // Evaluate pieces and mobility
     score += evaluate_pieces<KNIGHT, WHITE, Trace>(pos, ei, mobility, mobilityArea);
 
     // Evaluate pieces and mobility
     score += evaluate_pieces<KNIGHT, WHITE, Trace>(pos, ei, mobility, mobilityArea);