+ return file_bb(file_of(s));
+}
+
+
+/// shift() moves a bitboard one or two steps as specified by the direction D
+
+template<Direction D>
+constexpr Bitboard shift(Bitboard b) {
+ return D == NORTH ? b << 8 : D == SOUTH ? b >> 8
+ : D == NORTH+NORTH? b <<16 : D == SOUTH+SOUTH? b >>16
+ : D == EAST ? (b & ~FileHBB) << 1 : D == WEST ? (b & ~FileABB) >> 1
+ : D == NORTH_EAST ? (b & ~FileHBB) << 9 : D == NORTH_WEST ? (b & ~FileABB) << 7
+ : D == SOUTH_EAST ? (b & ~FileHBB) >> 7 : D == SOUTH_WEST ? (b & ~FileABB) >> 9
+ : 0;
+}
+
+
+/// pawn_attacks_bb() returns the squares attacked by pawns of the given color
+/// from the squares in the given bitboard.
+
+template<Color C>
+constexpr Bitboard pawn_attacks_bb(Bitboard b) {
+ return C == WHITE ? shift<NORTH_WEST>(b) | shift<NORTH_EAST>(b)
+ : shift<SOUTH_WEST>(b) | shift<SOUTH_EAST>(b);
+}
+
+inline Bitboard pawn_attacks_bb(Color c, Square s) {
+
+ assert(is_ok(s));
+ return PawnAttacks[c][s];