X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fbitboard.h;h=cf948afc7c9398f4b63aa56d79409d34acc7f89c;hp=c9f724277a6f5d5efabc82d0958396741a6aa35e;hb=2e21aba8d937bdf5eb0eedeac99ac2c2553e9d0d;hpb=9afa1d73306cb98e95acec5daf4efd65e592ceff diff --git a/src/bitboard.h b/src/bitboard.h index c9f72427..cf948afc 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -161,6 +161,16 @@ constexpr Bitboard shift(Bitboard b) { } +/// pawn_attacks_bb() returns the pawn attacks for the given color from the +/// squares in the given bitboard. + +template +constexpr Bitboard 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. @@ -179,9 +189,9 @@ inline Bitboard between_bb(Square s1, Square s2) { } -/// forward_ranks_bb() returns a bitboard representing all the squares on all the ranks -/// in front of the given one, from the point of view of the given color. For -/// instance, forward_ranks_bb(BLACK, SQ_D3) will return the 16 squares on ranks 1 and 2. +/// forward_ranks_bb() returns a bitboard representing the squares on all the ranks +/// in front of the given one, from the point of view of the given color. For instance, +/// forward_ranks_bb(BLACK, SQ_D3) will return the 16 squares on ranks 1 and 2. inline Bitboard forward_ranks_bb(Color c, Square s) { return ForwardRanksBB[c][rank_of(s)];