90 [[nodiscard]]
static auto from_string(std::string_view text) -> std::expected<Square, std::string>;
98 [[nodiscard]] constexpr auto operator==(const
Square&) const noexcept ->
bool = default;
104 [[nodiscard]] constexpr auto
is_queenside() const noexcept ->
bool;
107 [[nodiscard]] constexpr auto
is_kingside() const noexcept ->
bool;
118 [[nodiscard]] constexpr auto
is_light() const noexcept ->
bool;
121 [[nodiscard]] constexpr auto
is_dark() const noexcept ->
bool {
return not
is_light(); }
132 -> std::strong_ordering
134 return first.index() <=> second.index();
141 Square targetSquare,
bool isWhite)
noexcept
156struct std::formatter<
chess::board::Square> final {
157 template <
typename ParseContext>
158 constexpr auto parse(ParseContext& ctx) ->
typename ParseContext::iterator
163 template <
typename FormatContext>
166 ->
typename FormatContext::iterator
168 return std::format_to(ctx.out(),
"{}{}", square.file, square.rank);
204 (
static_cast<int>(
rank) << 3) +
static_cast<int>(
file));
209 return std::cmp_less_equal(
210 std::to_underlying(
file), std::to_underlying(
File::D));
215 return std::cmp_greater_equal(
216 std::to_underlying(
file), std::to_underlying(
File::E));
221 return std::cmp_less_equal(
227 return std::cmp_greater_equal(
234 std::to_underlying(
rank) + std::to_underlying(
file));
238 -> std::expected<Square, std::string>
240 if (std::cmp_not_equal(text.length(), 2)) {
241 return std::unexpected {
243 "Cannot parse Square from invalid input string: {}",
249 .and_then([fileChar = text.front()](
const Rank rankToUse) {
250 return file_from_char(fileChar)
251 .transform([rankToUse](const File fileToUse) {
261 const Square targetSquare,
const bool isWhite)
noexcept
266 const auto capturedRank = isWhite
271 .file = targetSquare.file,
constexpr auto prev_pawn_rank(Rank rank) noexcept -> Rank
std::uint_fast8_t BitboardIndex
auto rank_from_char(char character) -> std::expected< Rank, std::string >
constexpr auto operator<=>(const Square &first, const Square &second) noexcept -> std::strong_ordering
constexpr BitboardIndex MAX_BITBOARD_IDX
@ One
The first rank. This is the rank that white's king starts on.
@ E
The E file. This is the file that the kings start on.
@ D
The D file. This is the file that the queens start on.
constexpr auto is_even(const T value) noexcept -> bool
constexpr auto get_en_passant_captured_square(Square targetSquare, bool isWhite) noexcept -> Square
constexpr auto is_dark() const noexcept -> bool
constexpr auto is_kingside() const noexcept -> bool
static auto from_string(std::string_view text) -> std::expected< Square, std::string >
constexpr auto is_light() const noexcept -> bool
constexpr auto index() const noexcept -> BitboardIndex
constexpr auto is_black_territory() const noexcept -> bool
static constexpr auto from_index(BitboardIndex index) noexcept -> Square
constexpr auto is_queenside() const noexcept -> bool
constexpr auto is_white_territory() const noexcept -> bool