]> git.sesse.net Git - stockfish/commitdiff
Pinned pieces affect king safety
authorStefan Geschwentner <Stefan.Geschwentner@web.de>
Fri, 28 Mar 2014 07:41:50 +0000 (08:41 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 29 Mar 2014 07:37:55 +0000 (08:37 +0100)
Here the new idea is to link pinned pieces
with king safety.

Passed both STC
LLR: 2.96 (-2.94,2.94) [-1.50,4.50]
Total: 10047 W: 1867 L: 1737 D: 6443

And LTC
LLR: 2.97 (-2.94,2.94) [0.00,6.00]
Total: 10419 W: 1692 L: 1543 D: 7184

bench: 8325087

src/evaluate.cpp

index 99e9f0475281111fff761ad0f4f0b0f33e7e3968..8c84ac299777e7ff7a33f91cb2f9e439de783686 100644 (file)
@@ -204,6 +204,8 @@ namespace {
   const int BishopCheck       = 2;
   const int KnightCheck       = 3;
 
+  const int UnsupportedPinnedPiece = 2;
+
   // KingDanger[Color][attackUnits] contains the actual king danger weighted
   // scores, indexed by color and by a calculated integer number.
   Score KingDanger[COLOR_NB][128];
@@ -693,6 +695,10 @@ Value do_evaluate(const Position& pos) {
         if (b)
             attackUnits += KnightCheck * popcount<Max15>(b);
 
+        // Penalty for pinned pieces not defended by a pawn
+        if (ei.pinnedPieces[Us] & ~ei.attackedBy[Us][PAWN])
+            attackUnits += UnsupportedPinnedPiece;
+
         // To index KingDanger[] attackUnits must be in [0, 99] range
         attackUnits = std::min(99, std::max(0, attackUnits));