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>
159 constexpr auto parse(ParseContext& ctx) ->
typename ParseContext::iterator
164 template <
typename FormatContext>
168 ->
typename FormatContext::iterator
170 return std::format_to(ctx.out(),
"{}{}", square.file, square.rank);
206 (
static_cast<int>(
rank) << 3) +
static_cast<int>(
file));
211 return std::cmp_less_equal(
212 std::to_underlying(
file), std::to_underlying(
File::D));
217 return std::cmp_greater_equal(
218 std::to_underlying(
file), std::to_underlying(
File::E));
223 return std::cmp_less_equal(
229 return std::cmp_greater_equal(
236 std::to_underlying(
rank) + std::to_underlying(
file));
240 -> std::expected<Square, std::string>
242 if (std::cmp_not_equal(text.length(), 2)) {
243 return std::unexpected {
245 "Cannot parse Square from invalid input string: {}",
251 .and_then([fileChar = text.front()](
const Rank rankToUse) {
252 return file_from_char(fileChar)
253 .transform([rankToUse](const File fileToUse) {
263 const Square targetSquare,
const bool isWhite)
noexcept
268 const auto capturedRank = isWhite
273 .file = targetSquare.file,
constexpr auto prev_pawn_rank(Rank rank) noexcept -> Rank
constexpr auto operator<=>(const Square first, const Square second) noexcept -> std::strong_ordering
std::uint_fast8_t BitboardIndex
auto rank_from_char(char character) -> std::expected< Rank, std::string >
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