stellar

UCI Chess engine written in C++20
git clone git://git.dimitrijedobrota.com/stellar.git
Log | Files | Refs | README | LICENSE

pawn.hpp (1021B)


0 #ifndef STELLAR_ATTACK_PAWN_H 1 #define STELLAR_ATTACK_PAWN_H 2 3 #include "bit.hpp" 4 #include "bitboard.hpp" 5 #include "utils.hpp" 6 7 #include <array> 8 9 namespace attack { 10 namespace pawn { 11 12 static constexpr U64 mask_white(const Square square) { 13 U64 bitboard = C64(0); 14 15 bit::set(bitboard, square); 16 return bitboard::noWeOne(bitboard) | bitboard::noEaOne(bitboard); 17 } 18 19 static constexpr U64 mask_black(const Square square) { 20 U64 bitboard = C64(0); 21 22 bit::set(bitboard, square); 23 return bitboard::soWeOne(bitboard) | bitboard::soEaOne(bitboard); 24 } 25 26 typedef std::array<std::array<U64, 64>, 2> attack_array; 27 const auto attacks = []() { 28 attack_array attacks; 29 30 for (Square square = Square::a1; square <= Square::h8; ++square) { 31 attacks[WHITE][square] = mask_white(square); 32 attacks[BLACK][square] = mask_black(square); 33 } 34 35 return attacks; 36 }(); 37 38 inline constexpr U64 attack(Color color, Square square) { return attacks[color][square]; } 39 40 } // namespace pawn 41 } // namespace attack 42 43 #endif