// Enemies not defended by a pawn and under our attack
weak = pos.pieces(Them)
& ~ei.attackedBy[Them][PAWN]
& ei.attackedBy[Us][ALL_PIECES];
// Enemies not defended by a pawn and under our attack
weak = pos.pieces(Them)
& ~ei.attackedBy[Them][PAWN]
& ei.attackedBy[Us][ALL_PIECES];
There are even more pins for instance after d3d4 knight can not move for white will play b5b6. So there are pieces that shield weak squares like square c7.
Maybe give a penalty to each weak square. But it might be difficult or expensive to detect weak squares.
[d] 1k1r1bnr/1pp1p3/5pp1/pPN1n2p/2P2B2/3P4/P3BPPP/1R1R2K1 w - - 0 22