]> git.sesse.net Git - stockfish/blobdiff - src/evaluate.cpp
Bonus for pawn scrifice which create passed pawn
[stockfish] / src / evaluate.cpp
index 2f60edda31bb367aa01bb78221d0d5191d971797..92ad6e9a28ceee7ba7cd11bde5ed46164ed45a8b 100644 (file)
@@ -424,7 +424,7 @@ namespace {
         // number and types of the enemy's attacking pieces, the number of
         // attacked and undefended squares around our king and the quality of
         // the pawn shelter (current 'score' value).
-        kingDanger =  std::min(820, ei.kingAttackersCount[Them] * ei.kingAttackersWeight[Them])
+        kingDanger =        ei.kingAttackersCount[Them] * ei.kingAttackersWeight[Them]
                     + 103 * ei.kingAdjacentZoneAttacksCount[Them]
                     + 190 * popcount(undefended)
                     + 142 * (popcount(b) + !!pos.pinned_pieces(Us))
@@ -618,7 +618,7 @@ namespace {
     {
         Square s = pop_lsb(&b);
 
-        assert(!(pos.pieces(PAWN) & forward_bb(Us, s)));
+        assert(!(pos.pieces(Them, PAWN) & forward_bb(Us, s + pawn_push(Us))));
 
         bb = forward_bb(Us, s) & (ei.attackedBy[Them][ALL_PIECES] | pos.pieces(Them));
         score -= HinderPassedPawn * popcount(bb);
@@ -675,8 +675,8 @@ namespace {
         } // rr != 0
 
         // Scale down bonus for candidate passers which need more than one
-        // pawn push to become passed.
-        if (!pos.pawn_passed(Us, s + pawn_push(Us)))
+        // pawn push to become passed or have a pawn in front of them.
+        if (!pos.pawn_passed(Us, s + pawn_push(Us)) || (pos.pieces(PAWN) & forward_bb(Us, s)))
             mbonus /= 2, ebonus /= 2;
 
         score += make_score(mbonus, ebonus) + PassedFile[file_of(s)];