if (Pt == ROOK)
{
- // Bonus for aligning rook with with enemy pawns on the same rank/file
+ // Bonus for aligning rook with enemy pawns on the same rank/file
if (relative_rank(Us, s) >= RANK_5)
score += RookOnPawn * popcount(pos.pieces(Them, PAWN) & PseudoAttacks[ROOK][s]);
// Non-pawn enemies attacked by a pawn
nonPawnEnemies = pos.pieces(Them) ^ pos.pieces(Them, PAWN);
- weak = nonPawnEnemies & attackedBy[Us][PAWN];
- if (weak)
- {
- // Our safe or protected pawns
- b = pos.pieces(Us, PAWN)
- & (~attackedBy[Them][ALL_PIECES] | attackedBy[Us][ALL_PIECES]);
+ // Our safe or protected pawns
+ b = pos.pieces(Us, PAWN)
+ & (~attackedBy[Them][ALL_PIECES] | attackedBy[Us][ALL_PIECES]);
- safeThreats = pawn_attacks_bb<Us>(b) & weak;
- score += ThreatBySafePawn * popcount(safeThreats);
- }
+ safeThreats = pawn_attacks_bb<Us>(b) & nonPawnEnemies;
+ score += ThreatBySafePawn * popcount(safeThreats);
// Squares strongly protected by the enemy, either because they defend the
// square with a pawn, or because they defend the square twice and we don't.
}
else if (pos.pieces(Us) & blockSq)
bonus += make_score(w + r * 2, w + r * 2);
- } // rr != 0
+ } // w != 0
// Scale down bonus for candidate passers which need more than one
// pawn push to become passed or have a pawn in front of them.