]> git.sesse.net Git - stockfish/blobdiff - src/evaluate.cpp
Restrict mobility of pinned pieces
[stockfish] / src / evaluate.cpp
index 5b1f4f40ce493c0546a8944c7febb8cf717b5048..279802387402906e969f1361eb2051a03a04efe7 100644 (file)
@@ -83,6 +83,8 @@ namespace {
     // king is on g8 and there's a white knight on g5, this knight adds
     // 2 to kingAdjacentZoneAttacksCount[BLACK].
     int kingAdjacentZoneAttacksCount[COLOR_NB];
+
+    Bitboard pinnedPieces[COLOR_NB];
   };
 
   // Evaluation grain size, must be a power of 2
@@ -423,6 +425,8 @@ Value do_evaluate(const Position& pos) {
     const Color  Them = (Us == WHITE ? BLACK : WHITE);
     const Square Down = (Us == WHITE ? DELTA_S : DELTA_N);
 
+    ei.pinnedPieces[Us] = pos.pinned_pieces(Us);
+
     Bitboard b = ei.attackedBy[Them][KING] = pos.attacks_from<KING>(pos.king_square(Them));
     ei.attackedBy[Us][PAWN] = ei.pi->pawn_attacks(Us);
 
@@ -487,6 +491,9 @@ Value do_evaluate(const Position& pos) {
           : Piece ==   ROOK ? attacks_bb<  ROOK>(s, pos.pieces() ^ pos.pieces(Us, ROOK, QUEEN))
                             : pos.attacks_from<Piece>(s);
 
+        if (ei.pinnedPieces[Us] & s)
+            b &= PseudoAttacks[QUEEN][pos.king_square(Us)];
+
         ei.attackedBy[Us][Piece] |= b;
 
         if (b & ei.kingRing[Them])