- neighbours = ourPawns & adjacent_files_bb(f);
- doubled = ourPawns & forward_bb(Us, s);
- opposed = theirPawns & forward_bb(Us, s);
- passed = !(theirPawns & passed_pawn_mask(Us, s));
- lever = theirPawns & pawnAttacksBB[s];
- phalanx = neighbours & rank_bb(s);
- supported = neighbours & rank_bb(s - Up);
- connected = supported | phalanx;
- isolated = !neighbours;
-
- // Test for backward pawn.
- // If the pawn is passed, isolated, lever or connected it cannot be
- // backward. If there are friendly pawns behind on adjacent files
- // or if it is sufficiently advanced, it cannot be backward either.
- if ( (passed | isolated | lever | connected)
- || (ourPawns & pawn_attack_span(Them, s))
- || (relative_rank(Us, s) >= RANK_5))
+ opposed = theirPawns & forward_bb(Us, s);
+ stoppers = theirPawns & passed_pawn_mask(Us, s);
+ lever = theirPawns & pawnAttacksBB[s];
+ doubled = ourPawns & (s + Up);
+ neighbours = ourPawns & adjacent_files_bb(f);
+ phalanx = neighbours & rank_bb(s);
+ supported = neighbours & rank_bb(s - Up);
+ connected = supported | phalanx;
+
+ // 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)