X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fbitboard.h;h=9fc53ee760dba05673157faaa841b933e61e34f4;hp=5cafcfcc1a7987e62852e3778d780e2015887e38;hb=2c5dfb312205de03239cb15e79b501789c4cd067;hpb=52f92d05a9eae0cc68a3cd157f8df35802a98297 diff --git a/src/bitboard.h b/src/bitboard.h index 5cafcfcc..9fc53ee7 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -150,7 +150,17 @@ inline Bitboard file_bb(Square s) { } -/// shift() moves a bitboard one step along direction D. Mainly for pawns +/// make_bitboard() returns a bitboard from a list of squares + +constexpr Bitboard make_bitboard() { return 0; } + +template +constexpr Bitboard make_bitboard(Square s, Squares... squares) { + return (1ULL << s) | make_bitboard(squares...); +} + + +/// shift() moves a bitboard one step along direction D (mainly for pawns) template constexpr Bitboard shift(Bitboard b) { @@ -160,15 +170,17 @@ constexpr Bitboard shift(Bitboard b) { : 0; } + /// pawn_attacks_bb() returns the pawn attacks for the given color from the /// squares in the given bitboard. -template +template constexpr Bitboard pawn_attacks_bb(Bitboard b) { - return c == WHITE ? shift(b) | shift(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. @@ -187,9 +199,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)];