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
3 #include "bit.hpp"
4 #include "bitboard.hpp"
5 #include "utils.hpp"
7 #include <array>
9 namespace attack {
10 namespace pawn {
12 static constexpr U64 mask_white(const Square square) {
13 U64 bitboard = C64(0);
15 bit::set(bitboard, square);
16 return bitboard::noWeOne(bitboard) | bitboard::noEaOne(bitboard);
17 }
19 static constexpr U64 mask_black(const Square square) {
20 U64 bitboard = C64(0);
22 bit::set(bitboard, square);
23 return bitboard::soWeOne(bitboard) | bitboard::soEaOne(bitboard);
24 }
26 typedef std::array<std::array<U64, 64>, 2> attack_array;
27 const auto attacks = []() {
28 attack_array attacks;
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 }
35 return attacks;
36 }();
38 inline constexpr U64 attack(Color color, Square square) { return attacks[color][square]; }
40 } // namespace pawn
41 } // namespace attack
43 #endif