|
BenBot 1.7.5
A chess engine
|
#include <libchess/board/Square.hpp>
Public Member Functions | |
| constexpr auto | index () const noexcept -> BitboardIndex |
| constexpr auto | is_dark () const noexcept -> bool |
| constexpr auto | is_light () const noexcept -> bool |
| constexpr auto | operator== (const Square &) const noexcept -> bool=default |
Area queries | |
| constexpr auto | is_queenside () const noexcept -> bool |
| constexpr auto | is_kingside () const noexcept -> bool |
| constexpr auto | is_white_territory () const noexcept -> bool |
| constexpr auto | is_black_territory () const noexcept -> bool |
Static Public Member Functions | |
| static constexpr auto | from_index (BitboardIndex index) noexcept -> Square |
| static auto | from_string (std::string_view text) -> std::expected< Square, std::string > |
Public Attributes | |
| File | file { File::A } |
| Rank | rank { Rank::One } |
Related Symbols | |
(Note that these are not member symbols.) | |
| constexpr auto | file_distance (const Square &first, const Square &second) noexcept -> BitboardIndex |
| constexpr auto | rank_distance (const Square &first, const Square &second) noexcept -> BitboardIndex |
| constexpr auto | are_on_same_diagonal (const Square &first, const Square &second) noexcept -> bool |
| constexpr auto | manhattan_distance (const Square &first, const Square &second) noexcept -> BitboardIndex |
| constexpr auto | center_manhattan_distance (const Square &square) noexcept -> BitboardIndex |
| constexpr auto | chebyshev_distance (const Square &first, const Square &second) noexcept -> BitboardIndex |
| auto | knight_distance (const Square &first, const Square &second) -> BitboardIndex |
| constexpr auto | operator<=> (const Square &first, const Square &second) noexcept -> std::strong_ordering |
This struct uniquely identifies a square on the chessboard via its rank and file, and provides mappings to and from bitboard indices.
This class uses the "Least Significant File" mapping to calculate bitboard indices, as opposed to the "Least Significant Rank" mapping. This means that ranks are aligned to the eight consecutive bytes of a bitboard.
This results in the following mapping of squares to bitboard indices:
| Rank | A | B | C | D | E | F | G | H |
|---|---|---|---|---|---|---|---|---|
| 8 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
| 7 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 |
| 6 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 |
| 5 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
| 4 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
| 3 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
Definition at line 72 of file Square.hpp.
|
staticnodiscardconstexprnoexcept |
Calculates the rank and file corresponding to the given bitboard index. This function asserts if the passed index is greater than 63.
Definition at line 191 of file Square.hpp.
|
inlinestaticnodiscard |
Creates a square from a string in algebraic notation, such as "A1", "H4", etc.
This method recognizes either upper- or lower-case file letters.
If the input string cannot be parsed correctly, returns an explanatory error string.
Definition at line 237 of file Square.hpp.
|
nodiscardconstexprnoexcept |
Returns the bitboard bit index for this square. The returned index will be in the range [0,63].
Definition at line 201 of file Square.hpp.
|
nodiscardconstexprnoexcept |
Returns true if this square is within Black's territory (the fifth through eighth ranks).
Definition at line 225 of file Square.hpp.
|
inlinenodiscardconstexprnoexcept |
Returns true if this is a dark square.
Definition at line 121 of file Square.hpp.
|
nodiscardconstexprnoexcept |
Returns true if this square is on the kingside (the E-H files).
Definition at line 213 of file Square.hpp.
|
nodiscardconstexprnoexcept |
Returns true if this is a light square.
Definition at line 231 of file Square.hpp.
|
nodiscardconstexprnoexcept |
Returns true if this square is on the queenside (the A-D files).
Definition at line 207 of file Square.hpp.
|
nodiscardconstexprnoexcept |
Returns true if this square is within White's territory (the first through fourth ranks).
Definition at line 219 of file Square.hpp.
|
nodiscardconstexprdefaultnoexcept |
Returns true if two squares are equivalent.
This square's file.
Definition at line 74 of file Square.hpp.
This square's rank.
Definition at line 77 of file Square.hpp.