stellar

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

pawnb.hpp (857B)


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