Chess Engine
A Chess Engine project written in C++.
Loading...
Searching...
No Matches
castling.hpp
1#pragma once
2
3#include <cstdint>
4
5struct Castling {
6 enum : std::uint8_t {
7 W_KING_SIDE = 0b0001,
8 W_QUEEN_SIDE = 0b0010,
9 B_KING_SIDE = 0b0100,
10 B_QUEEN_SIDE = 0b1000,
11
12 KING_SIDE = W_KING_SIDE | B_KING_SIDE, // 0b0101
13 QUEEN_SIDE = W_QUEEN_SIDE | B_QUEEN_SIDE, // 0b1010
14 W_SIDE = W_KING_SIDE | W_QUEEN_SIDE, // 0b0011
15 B_SIDE = B_KING_SIDE | B_QUEEN_SIDE, // 0b1100
16 ANY = W_SIDE | B_SIDE, // 0b1111
17
18 NONE = 0b0000,
19
20 MASK = 0b1111,
21 SIZE = 4,
22 NB = 4
23 };
24
25 constexpr Castling(uint8_t value) : m_value(value) {}
26
27 [[nodiscard]] static constexpr uint8_t none() { return NONE; }
28
29 [[nodiscard]] static constexpr uint8_t number() { return NB; }
30 [[nodiscard]] static constexpr uint8_t mask() { return MASK; }
31 [[nodiscard]] static constexpr uint8_t size() { return SIZE; }
32
33 constexpr operator uint8_t() const { return m_value; }
34
35 private:
36 uint8_t m_value;
37};