]> git.sesse.net Git - stockfish/blobdiff - src/pawns.cpp
Simplify the backward pawns code
[stockfish] / src / pawns.cpp
index 6623ab71b80b9db18c59a9cbdfba11c62a3c89cd..ca9c302322be35fcc8383cd9f3b925691888fdf9 100644 (file)
@@ -116,22 +116,10 @@ namespace {
         phalanx    = neighbours & rank_bb(s);
         supported  = neighbours & rank_bb(s - Up);
 
         phalanx    = neighbours & rank_bb(s);
         supported  = neighbours & rank_bb(s - Up);
 
-        // A pawn is backward when it is behind all pawns of the same color on the
-        // adjacent files and cannot be safely advanced.
-        if (!neighbours || lever || relative_rank(Us, s) >= RANK_5)
-            backward = false;
-        else
-        {
-            // Find the backmost rank with neighbours or stoppers
-            b = rank_bb(backmost_sq(Us, neighbours | stoppers));
-
-            // The pawn is backward when it cannot safely progress to that rank:
-            // either there is a stopper in the way on this rank, or there is a
-            // stopper on adjacent file which controls the way to that rank.
-            backward = (b | shift<Up>(b & adjacent_files_bb(f))) & stoppers;
-
-            assert(!(backward && (forward_ranks_bb(Them, s + Up) & neighbours)));
-        }
+        // A pawn is backward when it is behind all pawns of the same color
+        // on the adjacent files and cannot be safely advanced.
+        backward = !lever && !(ourPawns & pawn_attack_span(Them, s + Up))
+                          &&  (stoppers & (leverPush | (s + Up)));
 
         // Passed pawns will be properly scored in evaluation because we need
         // full attack info to evaluate them. Include also not passed pawns
 
         // Passed pawns will be properly scored in evaluation because we need
         // full attack info to evaluate them. Include also not passed pawns