Bitboard b, bb;
Square s;
Score score = SCORE_ZERO;
+ int mob;
attackedBy[Us][Pt] = 0;
kingAttacksCount[Us] += popcount(b & attackedBy[Them][KING]);
}
- int mob = popcount(b & mobilityArea[Us]);
+ mob = (Pt == KNIGHT || Pt == BISHOP) ? popcount(b & mobilityArea[Us] & ~pos.pieces(Us, QUEEN))
+ : popcount(b & mobilityArea[Us]);
mobility[Us] += MobilityBonus[Pt - 2][mob];
// 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.