X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fbitboard.h;h=b64c92e1a4c54107ef2088ddf43d69c9cafc6871;hb=242c566c1a80c7f3d95774eac513935fcee0cf0d;hp=559c70f62acf9e5f056d26f205fa6dc2aa24f38f;hpb=cf5d683408a2ef8a1c80be9bf7d6790a38b16277;p=stockfish diff --git a/src/bitboard.h b/src/bitboard.h index 559c70f6..b64c92e1 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -60,12 +60,11 @@ constexpr Bitboard Rank6BB = Rank1BB << (8 * 5); constexpr Bitboard Rank7BB = Rank1BB << (8 * 6); constexpr Bitboard Rank8BB = Rank1BB << (8 * 7); -extern int SquareDistance[SQUARE_NB][SQUARE_NB]; +extern int8_t SquareDistance[SQUARE_NB][SQUARE_NB]; extern Bitboard SquareBB[SQUARE_NB]; extern Bitboard FileBB[FILE_NB]; extern Bitboard RankBB[RANK_NB]; -extern Bitboard AdjacentFilesBB[FILE_NB]; extern Bitboard ForwardRanksBB[COLOR_NB][RANK_NB]; extern Bitboard BetweenBB[SQUARE_NB][SQUARE_NB]; extern Bitboard LineBB[SQUARE_NB][SQUARE_NB]; @@ -135,6 +134,10 @@ 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,11 +180,21 @@ 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. inline Bitboard adjacent_files_bb(File f) { - return AdjacentFilesBB[f]; + return shift(FileBB[f]) | shift(FileBB[f]); }