]> git.sesse.net Git - stockfish/blobdiff - src/evaluate.cpp
Add bonuses for Minors attacking enemy pieces(except pawns) even when they are protec...
[stockfish] / src / evaluate.cpp
index dedecfd16c73defa50fefb664189189cf8a898cd..f17c575d2cfeb775a5c54afacf6875988becde80 100644 (file)
@@ -496,9 +496,17 @@ namespace {
 
     const Color Them = (Us == WHITE ? BLACK : WHITE);
 
-    Bitboard b, weakEnemies;
+    Bitboard b, weakEnemies, protectedEnemies;
     Score score = SCORE_ZERO;
 
+    // Protected enemies
+    protectedEnemies = (pos.pieces(Them) ^ pos.pieces(Them,PAWN))
+                      & ei.attackedBy[Them][PAWN]
+                      & (ei.attackedBy[Us][KNIGHT] | ei.attackedBy[Us][BISHOP]);
+
+    if(protectedEnemies)
+        score += Threat[0][type_of(pos.piece_on(lsb(protectedEnemies)))];
+
     // Enemies not defended by a pawn and under our attack
     weakEnemies =  pos.pieces(Them)
                  & ~ei.attackedBy[Them][PAWN]
@@ -750,8 +758,10 @@ namespace {
                 // Endgame with opposite-colored bishops, but also other pieces. Still
                 // a bit drawish, but not as drawish as with only the two bishops.
                  sf = ScaleFactor(50 * sf / SCALE_FACTOR_NORMAL);
-        } else if ( ei.pi->pawn_span(strongSide) <= 1 &&
-                   !pos.pawn_passed(~strongSide, pos.king_square(~strongSide))) {
+        } else if (    abs(eg_value(score)) <= BishopValueEg
+                   &&  ei.pi->pawn_span(strongSide) <= 1
+                   && !pos.pawn_passed(~strongSide, pos.king_square(~strongSide))) {
+            // Endings where weaker side can be place his king in front of the opponent's pawns are drawish.
             sf = ScaleFactor(ScalePawnSpan[ei.pi->pawn_span(strongSide)]);
         }
     }