diff --git a/src/bitboard.h b/src/bitboard.h index 559c70f6..c6dbc647 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -177,6 +177,16 @@ constexpr Bitboard pawn_attacks_bb(Bitboard b) { } +/// double_pawn_attacks_bb() returns the pawn attacks for the given color +/// from the squares in the given bitboard. + +template +constexpr Bitboard double_pawn_attacks_bb(Bitboard b) { + return C == WHITE ? shift(b) & shift(b) + : shift(b) & shift(b); +} + + /// adjacent_files_bb() returns a bitboard representing all the squares on the /// adjacent files of the given one. diff --git a/src/evaluate.cpp b/src/evaluate.cpp index f1bb861d..d6239594 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -309,7 +309,7 @@ namespace { attackedBy[Us][Pt] |= b; attackedBy[Us][ALL_PIECES] |= b; - if (b & kingRing[Them]) + if (b & kingRing[Them] & ~double_pawn_attacks_bb(pos.pieces(Them, PAWN))) { kingAttackersCount[Us]++; kingAttackersWeight[Us] += KingAttackWeights[Pt];