- // Undefended minors get penalized even if not under attack
- Bitboard undefended = pos.pieces(Them)
- & (pos.pieces(BISHOP) | pos.pieces(KNIGHT))
- & ~ei.attackedBy[Them][0];
- if (undefended)
- score += single_bit(undefended) ? UndefendedMinorPenalty
- : UndefendedMinorPenalty * 2;
+ // Undefended pieces get penalized even if not under attack
+ undefended = pos.pieces(Them) & ~ei.attackedBy[Them][0];
+ undefendedMinors = undefended & (pos.pieces(BISHOP) | pos.pieces(KNIGHT));
+
+ if (undefendedMinors)
+ score += single_bit(undefendedMinors) ? UndefendedPiecePenalty
+ : UndefendedPiecePenalty * 2;
+ if (undefended & pos.pieces(ROOK))
+ score += UndefendedPiecePenalty;