pawnb.hpp (857B)
1 #ifndef STELLAR_ATTACK_PAWNB_H 2 #define STELLAR_ATTACK_PAWNB_H 3 4 #include "bit.hpp" 5 #include "bitboard.hpp" 6 #include "square.hpp" 7 #include "utils.hpp" 8 9 #include <array> 10 11 namespace attack { 12 namespace pawnb { 13 14 static constexpr U64 mask(const square::Square square) { 15 U64 bitboard = C64(0); 16 17 bit::set(bitboard, to_underlying(square)); 18 return bitboard::soWeOne(bitboard) | bitboard::soEaOne(bitboard); 19 } 20 21 typedef std::array<U64, 64> attack_array; 22 const attack_array attacks = []() -> attack_array { 23 std::array<U64, 64> attacks; 24 for (uint8_t square = 0; square < 64; square++) 25 attacks[square] = mask(static_cast<square::Square>(square)); 26 return attacks; 27 }(); 28 29 inline constexpr U64 attack(const square::Square square, U64 occupancy) { 30 return attacks[to_underlying(square)]; 31 } 32 33 } // namespace pawnb 34 }; // namespace attack 35 36 #endif