X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fbitboard.h;h=f1db634f1bd058910ef32127bb9f6f956437dd9b;hb=a8e903c33a676decfcf5c721b6b4bfdb4102e5c0;hp=559c70f62acf9e5f056d26f205fa6dc2aa24f38f;hpb=cf5d683408a2ef8a1c80be9bf7d6790a38b16277;p=stockfish diff --git a/src/bitboard.h b/src/bitboard.h index 559c70f6..f1db634f 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -135,6 +135,11 @@ constexpr bool more_than_one(Bitboard b) { return b & (b - 1); } +inline bool opposite_colors(Square s1, Square s2) { + + return bool(DarkSquares & s1) != bool(DarkSquares & s2); +} + /// rank_bb() and file_bb() return a bitboard representing all the squares on /// the given file or rank. @@ -177,6 +182,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.