BenBot 1.7.5
A chess engine
Loading...
Searching...
No Matches
Board representation
Collaboration diagram for Board representation:

Topics

 Bitboard masks

Files

file  Bitboard.hpp
file  BitboardIndex.hpp
file  Distances.hpp
file  File.hpp
file  Fills.hpp
file  Flips.hpp
file  Pieces.hpp
file  Rank.hpp
file  Shifts.hpp
file  Square.hpp

Namespaces

namespace  chess
namespace  chess::board
namespace  chess::board::fills
namespace  chess::board::flips
namespace  chess::board::literals
namespace  chess::board::shifts

Classes

struct  chess::board::Bitboard
struct  std::formatter< chess::board::File >
struct  std::formatter< chess::board::Rank >
struct  std::formatter< chess::board::Square >
struct  chess::board::Pieces
struct  chess::board::Square

Typedefs

using chess::board::BitboardIndex = std::uint_fast8_t

Enumerations

enum class  chess::board::File : BitboardIndex {
  chess::board::File::A , chess::board::File::B , chess::board::File::C , chess::board::File::D ,
  chess::board::File::E , chess::board::File::F , chess::board::File::G , chess::board::File::H
}
enum class  chess::board::Rank : BitboardIndex {
  chess::board::Rank::One , chess::board::Rank::Two , chess::board::Rank::Three , chess::board::Rank::Four ,
  chess::board::Rank::Five , chess::board::Rank::Six , chess::board::Rank::Seven , chess::board::Rank::Eight
}

Functions

constexpr auto chess::board::back_rank_for (Color color) noexcept -> Rank
auto chess::board::file_from_char (char character) -> std::expected< File, std::string >
auto chess::board::file_to_char (File file) -> char
constexpr auto chess::board::flips::horizontal (Bitboard board) noexcept -> Bitboard
template<Color Side>
constexpr auto chess::board::next_pawn_rank (Rank rank) noexcept -> Rank
consteval auto operator""_bb (const unsigned long long value) noexcept -> Bitboard
template<Color Side>
constexpr auto chess::board::prev_pawn_rank (Rank rank) noexcept -> Rank
auto chess::board::rank_from_char (char character) -> std::expected< Rank, std::string >
constexpr auto chess::board::rank_to_char (Rank rank) -> char
constexpr auto chess::board::flips::vertical (Bitboard board) noexcept -> Bitboard

Variables

constexpr BitboardIndex chess::board::MAX_BITBOARD_IDX = NUM_SQUARES - UINT8_C(1)
constexpr BitboardIndex chess::board::NUM_SQUARES = UINT8_C(64)
constexpr auto chess::board::fills::north (Bitboard starting) noexcept -> Bitboard
constexpr auto chess::board::fills::south (Bitboard starting) noexcept -> Bitboard
constexpr auto chess::board::fills::east (Bitboard starting) noexcept -> Bitboard
constexpr auto chess::board::fills::west (Bitboard starting) noexcept -> Bitboard
constexpr auto chess::board::fills::northeast (Bitboard starting) noexcept -> Bitboard
constexpr auto chess::board::fills::southeast (Bitboard starting) noexcept -> Bitboard
constexpr auto chess::board::fills::northwest (Bitboard starting) noexcept -> Bitboard
constexpr auto chess::board::fills::southwest (Bitboard starting) noexcept -> Bitboard
constexpr auto chess::board::fills::file (Bitboard starting) noexcept -> Bitboard
constexpr auto chess::board::fills::rank (Bitboard starting) noexcept -> Bitboard
constexpr auto chess::board::fills::diagonal (Bitboard starting) noexcept -> Bitboard
constexpr auto chess::board::fills::antidiagonal (Bitboard starting) noexcept -> Bitboard
template<Color Side>
constexpr auto chess::board::fills::pawn_front (Bitboard starting) noexcept -> Bitboard
template<Color Side>
constexpr auto chess::board::fills::pawn_rear (Bitboard starting) noexcept -> Bitboard
constexpr auto chess::board::shifts::north (Bitboard board) noexcept -> Bitboard
constexpr auto chess::board::shifts::south (Bitboard board) noexcept -> Bitboard
constexpr auto chess::board::shifts::east (Bitboard board) noexcept -> Bitboard
constexpr auto chess::board::shifts::west (Bitboard board) noexcept -> Bitboard
constexpr auto chess::board::shifts::northeast (Bitboard board) noexcept -> Bitboard
constexpr auto chess::board::shifts::northwest (Bitboard board) noexcept -> Bitboard
constexpr auto chess::board::shifts::southeast (Bitboard board) noexcept -> Bitboard
constexpr auto chess::board::shifts::southwest (Bitboard board) noexcept -> Bitboard
template<Color Side>
constexpr auto chess::board::shifts::pawn_forward (Bitboard board) noexcept -> Bitboard
template<Color Side>
constexpr auto chess::board::shifts::pawn_backward (Bitboard board) noexcept -> Bitboard
template<Color Side>
constexpr auto chess::board::shifts::pawn_capture_east (Bitboard board) noexcept -> Bitboard
template<Color Side>
constexpr auto chess::board::shifts::pawn_capture_west (Bitboard board) noexcept -> Bitboard
template<Color Side>
constexpr auto chess::board::shifts::pawn_inv_capture_east (Bitboard board) noexcept -> Bitboard
template<Color Side>
constexpr auto chess::board::shifts::pawn_inv_capture_west (Bitboard board) noexcept -> Bitboard
constexpr auto operator& (const Bitboard &lhs, const Bitboard &rhs) noexcept -> Bitboard
constexpr auto operator| (const Bitboard &lhs, const Bitboard &rhs) noexcept -> Bitboard
constexpr auto operator^ (const Bitboard &lhs, const Bitboard &rhs) noexcept -> Bitboard
constexpr auto operator<< (const Bitboard &board, size_t num) noexcept -> Bitboard
constexpr auto operator>> (const Bitboard &board, size_t num) noexcept -> Bitboard
auto print_ascii (Bitboard board) -> std::string
constexpr auto operator| (const Bitboard &lhs, const Bitboard &rhs) noexcept -> Bitboard
constexpr auto operator^ (const Bitboard &lhs, const Bitboard &rhs) noexcept -> Bitboard
constexpr auto operator<< (const Bitboard &board, size_t num) noexcept -> Bitboard
constexpr auto operator>> (const Bitboard &board, size_t num) noexcept -> Bitboard
auto print_ascii (Bitboard board) -> std::string
constexpr auto operator| (const Bitboard &lhs, const Bitboard &rhs) noexcept -> Bitboard
constexpr auto operator^ (const Bitboard &lhs, const Bitboard &rhs) noexcept -> Bitboard
constexpr auto operator<< (const Bitboard &board, size_t num) noexcept -> Bitboard
constexpr auto operator>> (const Bitboard &board, size_t num) noexcept -> Bitboard
auto print_ascii (Bitboard board) -> std::string
constexpr auto operator| (const Bitboard &lhs, const Bitboard &rhs) noexcept -> Bitboard
constexpr auto operator^ (const Bitboard &lhs, const Bitboard &rhs) noexcept -> Bitboard
constexpr auto operator<< (const Bitboard &board, size_t num) noexcept -> Bitboard
constexpr auto operator>> (const Bitboard &board, size_t num) noexcept -> Bitboard
auto print_ascii (Bitboard board) -> std::string
constexpr auto operator| (const Bitboard &lhs, const Bitboard &rhs) noexcept -> Bitboard
constexpr auto operator^ (const Bitboard &lhs, const Bitboard &rhs) noexcept -> Bitboard
constexpr auto operator<< (const Bitboard &board, size_t num) noexcept -> Bitboard
constexpr auto operator>> (const Bitboard &board, size_t num) noexcept -> Bitboard
auto print_ascii (Bitboard board) -> std::string
constexpr auto operator| (const Bitboard &lhs, const Bitboard &rhs) noexcept -> Bitboard
constexpr auto operator^ (const Bitboard &lhs, const Bitboard &rhs) noexcept -> Bitboard
constexpr auto operator<< (const Bitboard &board, size_t num) noexcept -> Bitboard
constexpr auto operator>> (const Bitboard &board, size_t num) noexcept -> Bitboard
auto print_ascii (Bitboard board) -> std::string
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 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 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 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

Detailed Description

Classes related to the engine's internal board representation. libchess uses bitboards with "Least Significant File" encoding.

Typedef Documentation

◆ BitboardIndex

using chess::board::BitboardIndex = std::uint_fast8_t

Unsigned integer type used for bitboard indices. Valid bitboard indices are in the range [0, 63].

See also
NUM_SQUARES, MAX_BITBOARD_IDX

Definition at line 32 of file BitboardIndex.hpp.

Enumeration Type Documentation

◆ File

enum class chess::board::File : BitboardIndex
strong

This enum describes the files of the chess board.

See also
Rank
Enumerator

The A file.

The B file.

The C file.

The D file. This is the file that the queens start on.

The E file. This is the file that the kings start on.

The F file.

The G file.

The H file.

Definition at line 36 of file File.hpp.

◆ Rank

enum class chess::board::Rank : BitboardIndex
strong

This enum describes the ranks of the chessboard.

See also
File
Enumerator
One 

The first rank. This is the rank that white's king starts on.

Two 

The second rank. This is the rank that white's pawns start on.

Three 

The third rank.

Four 

The fourth rank.

Five 

The fifth rank.

Six 

The sixth rank.

Seven 

The seventh rank. This is the rank that black's pawns start on.

Eight 

The back rank. This is the rank that black's king starts on.

Definition at line 40 of file Rank.hpp.

Function Documentation

◆ antidiagonal()

auto chess::board::fills::antidiagonal ( Bitboard starting) -> Bitboard
nodiscardconstexprnoexcept

Performs an antidiagonal fill of the starting bitboard. For any antidiagonal in the starting bitboard with at least 1 bit set, the returned bitboard will have all bits on that antidiagonal set to 1.

Definition at line 228 of file Fills.hpp.

◆ are_on_same_diagonal() [1/4]

auto are_on_same_diagonal ( const Square & first,
const Square & second ) -> bool
related

Returns true if two squares are on the same diagonal of the chessboard. Two squares are on the same diagonal if their file distance equals their rank distance.

Definition at line 161 of file Distances.hpp.

◆ are_on_same_diagonal() [2/4]

auto are_on_same_diagonal ( const Square & first,
const Square & second ) -> bool
related

Returns true if two squares are on the same diagonal of the chessboard. Two squares are on the same diagonal if their file distance equals their rank distance.

Definition at line 161 of file Distances.hpp.

◆ are_on_same_diagonal() [3/4]

auto are_on_same_diagonal ( const Square & first,
const Square & second ) -> bool
related

Returns true if two squares are on the same diagonal of the chessboard. Two squares are on the same diagonal if their file distance equals their rank distance.

Definition at line 161 of file Distances.hpp.

◆ are_on_same_diagonal() [4/4]

auto are_on_same_diagonal ( const Square & first,
const Square & second ) -> bool
related

Returns true if two squares are on the same diagonal of the chessboard. Two squares are on the same diagonal if their file distance equals their rank distance.

Definition at line 161 of file Distances.hpp.

◆ back_rank_for()

auto chess::board::back_rank_for ( Color color) -> Rank
nodiscardconstexprnoexcept

Returns the back rank for the given side. A player's back rank is the rank their king starts on.

Definition at line 132 of file Rank.hpp.

◆ center_manhattan_distance() [1/4]

auto center_manhattan_distance ( const Square & square) -> BitboardIndex
related

Returns the smallest Manhattan distance from the given square to any of the four central squares. The maximum value is 6, from each of the 4 corners.

See also
manhattan_distance()

Definition at line 175 of file Distances.hpp.

◆ center_manhattan_distance() [2/4]

auto center_manhattan_distance ( const Square & square) -> BitboardIndex
related

Returns the smallest Manhattan distance from the given square to any of the four central squares. The maximum value is 6, from each of the 4 corners.

See also
manhattan_distance()

Definition at line 175 of file Distances.hpp.

◆ center_manhattan_distance() [3/4]

auto center_manhattan_distance ( const Square & square) -> BitboardIndex
related

Returns the smallest Manhattan distance from the given square to any of the four central squares. The maximum value is 6, from each of the 4 corners.

See also
manhattan_distance()

Definition at line 175 of file Distances.hpp.

◆ center_manhattan_distance() [4/4]

auto center_manhattan_distance ( const Square & square) -> BitboardIndex
related

Returns the smallest Manhattan distance from the given square to any of the four central squares. The maximum value is 6, from each of the 4 corners.

See also
manhattan_distance()

Definition at line 175 of file Distances.hpp.

◆ chebyshev_distance() [1/4]

auto chebyshev_distance ( const Square & first,
const Square & second ) -> BitboardIndex
related

Returns the Chebyshev distance between the two squares.

Chebyshev distance is the number of king moves required to travel between the squares on an otherwise-empty board. The difference with Manhattan distance is that diagonal king moves are considered.

The maximum Chebyshev distance is 7.

See also
manhattan_distance()

Definition at line 188 of file Distances.hpp.

◆ chebyshev_distance() [2/4]

auto chebyshev_distance ( const Square & first,
const Square & second ) -> BitboardIndex
related

Returns the Chebyshev distance between the two squares.

Chebyshev distance is the number of king moves required to travel between the squares on an otherwise-empty board. The difference with Manhattan distance is that diagonal king moves are considered.

The maximum Chebyshev distance is 7.

See also
manhattan_distance()

Definition at line 188 of file Distances.hpp.

◆ chebyshev_distance() [3/4]

auto chebyshev_distance ( const Square & first,
const Square & second ) -> BitboardIndex
related

Returns the Chebyshev distance between the two squares.

Chebyshev distance is the number of king moves required to travel between the squares on an otherwise-empty board. The difference with Manhattan distance is that diagonal king moves are considered.

The maximum Chebyshev distance is 7.

See also
manhattan_distance()

Definition at line 188 of file Distances.hpp.

◆ chebyshev_distance() [4/4]

auto chebyshev_distance ( const Square & first,
const Square & second ) -> BitboardIndex
related

Returns the Chebyshev distance between the two squares.

Chebyshev distance is the number of king moves required to travel between the squares on an otherwise-empty board. The difference with Manhattan distance is that diagonal king moves are considered.

The maximum Chebyshev distance is 7.

See also
manhattan_distance()

Definition at line 188 of file Distances.hpp.

◆ diagonal()

auto chess::board::fills::diagonal ( Bitboard starting) -> Bitboard
nodiscardconstexprnoexcept

Performs a diagonal fill of the starting bitboard. For any diagonal in the starting bitboard with at least 1 bit set, the returned bitboard will have all bits on that diagonal set to 1.

Definition at line 223 of file Fills.hpp.

◆ east() [1/2]

auto chess::board::fills::east ( Bitboard starting) -> Bitboard
nodiscardconstexprnoexcept

Performs an east fill of the starting bitboard.

Definition at line 129 of file Fills.hpp.

◆ east() [2/2]

auto chess::board::shifts::east ( Bitboard board) -> Bitboard
nodiscardconstexprnoexcept

Shifts all bits in the given board east (i.e., right one file).

Definition at line 119 of file Shifts.hpp.

◆ file()

auto chess::board::fills::file ( Bitboard starting) -> Bitboard
nodiscardconstexprnoexcept

Performs a file fill of the starting bitboard. For any file in the starting bitboard with at least 1 bit set, the returned bitboard will have all bits on that file set to 1.

Definition at line 213 of file Fills.hpp.

◆ file_distance()

auto file_distance ( const Square & first,
const Square & second ) -> BitboardIndex
related

Returns as an integer the distance between the file of the first square and the file of the second square.

The maximum file distance is 7.

See also
rank_distance()

Definition at line 137 of file Distances.hpp.

◆ file_from_char()

auto chess::board::file_from_char ( char character) -> std::expected< File, std::string >
inlinenodiscard

Interprets the given character as a file. This function recognizes upper- or lowercase file letters.

If the input string cannot be parsed correctly, returns an explanatory error string.

See also
File

Definition at line 108 of file File.hpp.

◆ file_to_char()

auto chess::board::file_to_char ( File file) -> char
inlinenodiscard

Converts the file enumeration to its single-character representation.

See also
File

Definition at line 145 of file File.hpp.

◆ horizontal()

auto chess::board::flips::horizontal ( Bitboard board) -> Bitboard
nodiscardconstexprnoexcept

Returns a copy of the bitboard, mirrored horizontally.

Definition at line 64 of file Flips.hpp.

◆ knight_distance() [1/4]

auto knight_distance ( const Square & first,
const Square & second ) -> BitboardIndex
related

Returns the knight distance between the two squares; that is, the number of moves a knight requires to maneuver from first to second.

The maximum knight distance is 6.

◆ knight_distance() [2/4]

auto knight_distance ( const Square & first,
const Square & second ) -> BitboardIndex
related

Returns the knight distance between the two squares; that is, the number of moves a knight requires to maneuver from first to second.

The maximum knight distance is 6.

◆ knight_distance() [3/4]

auto knight_distance ( const Square & first,
const Square & second ) -> BitboardIndex
related

Returns the knight distance between the two squares; that is, the number of moves a knight requires to maneuver from first to second.

The maximum knight distance is 6.

◆ knight_distance() [4/4]

auto knight_distance ( const Square & first,
const Square & second ) -> BitboardIndex
related

Returns the knight distance between the two squares; that is, the number of moves a knight requires to maneuver from first to second.

The maximum knight distance is 6.

◆ manhattan_distance() [1/4]

auto manhattan_distance ( const Square & first,
const Square & second ) -> BitboardIndex
related

Returns the Manhattan distance between the two squares.

Manhattan distance is the sum of the rank distance and file distance between the two squares. Therefore, this gives the number of non-diagonal king moves required to travel between the two squares.

The maximum Manhattan distance (between the ends of the long diagonals) is 14.

This may also be known as "taxicab" distance.

See also
chebyshev_distance(), center_manhattan_distance()

Definition at line 168 of file Distances.hpp.

◆ manhattan_distance() [2/4]

auto manhattan_distance ( const Square & first,
const Square & second ) -> BitboardIndex
related

Returns the Manhattan distance between the two squares.

Manhattan distance is the sum of the rank distance and file distance between the two squares. Therefore, this gives the number of non-diagonal king moves required to travel between the two squares.

The maximum Manhattan distance (between the ends of the long diagonals) is 14.

This may also be known as "taxicab" distance.

See also
chebyshev_distance(), center_manhattan_distance()

Definition at line 168 of file Distances.hpp.

◆ manhattan_distance() [3/4]

auto manhattan_distance ( const Square & first,
const Square & second ) -> BitboardIndex
related

Returns the Manhattan distance between the two squares.

Manhattan distance is the sum of the rank distance and file distance between the two squares. Therefore, this gives the number of non-diagonal king moves required to travel between the two squares.

The maximum Manhattan distance (between the ends of the long diagonals) is 14.

This may also be known as "taxicab" distance.

See also
chebyshev_distance(), center_manhattan_distance()

Definition at line 168 of file Distances.hpp.

◆ manhattan_distance() [4/4]

auto manhattan_distance ( const Square & first,
const Square & second ) -> BitboardIndex
related

Returns the Manhattan distance between the two squares.

Manhattan distance is the sum of the rank distance and file distance between the two squares. Therefore, this gives the number of non-diagonal king moves required to travel between the two squares.

The maximum Manhattan distance (between the ends of the long diagonals) is 14.

This may also be known as "taxicab" distance.

See also
chebyshev_distance(), center_manhattan_distance()

Definition at line 168 of file Distances.hpp.

◆ next_pawn_rank()

template<Color Side>
auto chess::board::next_pawn_rank ( Rank rank) -> Rank
nodiscardconstexprnoexcept

Returns the next pawn rank, from the given side's perspective.

Definition at line 141 of file Rank.hpp.

◆ north() [1/2]

auto chess::board::fills::north ( Bitboard starting) -> Bitboard
nodiscardconstexprnoexcept

Performs a north fill of the starting bitboard.

Definition at line 111 of file Fills.hpp.

◆ north() [2/2]

auto chess::board::shifts::north ( Bitboard board) -> Bitboard
nodiscardconstexprnoexcept

Shifts all bits in the given board north (i.e., up one rank).

Definition at line 109 of file Shifts.hpp.

◆ northeast() [1/2]

auto chess::board::fills::northeast ( Bitboard starting) -> Bitboard
nodiscardconstexprnoexcept

Performs a northeast fill of the starting bitboard.

Definition at line 157 of file Fills.hpp.

◆ northeast() [2/2]

auto chess::board::shifts::northeast ( Bitboard board) -> Bitboard
nodiscardconstexprnoexcept

Shifts all bits in the given board northeast.

Definition at line 133 of file Shifts.hpp.

◆ northwest() [1/2]

auto chess::board::fills::northwest ( Bitboard starting) -> Bitboard
nodiscardconstexprnoexcept

Performs a northwest fill of the starting bitboard.

Definition at line 185 of file Fills.hpp.

◆ northwest() [2/2]

auto chess::board::shifts::northwest ( Bitboard board) -> Bitboard
nodiscardconstexprnoexcept

Shifts all bits in the given board northwest.

Definition at line 140 of file Shifts.hpp.

◆ operator""_bb()

auto operator""_bb ( const unsigned long long value) -> Bitboard
related

Creates a bitboard from an integer literal value.

Definition at line 244 of file Bitboard.hpp.

◆ operator&()

auto operator& ( const Bitboard & lhs,
const Bitboard & rhs ) -> Bitboard
related

Returns the binary AND of two bitboards.

Definition at line 362 of file Bitboard.hpp.

◆ operator<<() [1/6]

auto operator<< ( const Bitboard & board,
size_t num ) -> Bitboard
related

Returns a copy of the bitboard with a binary shift left applied.

Definition at line 383 of file Bitboard.hpp.

◆ operator<<() [2/6]

auto operator<< ( const Bitboard & board,
size_t num ) -> Bitboard
related

Returns a copy of the bitboard with a binary shift left applied.

Definition at line 383 of file Bitboard.hpp.

◆ operator<<() [3/6]

auto operator<< ( const Bitboard & board,
size_t num ) -> Bitboard
related

Returns a copy of the bitboard with a binary shift left applied.

Definition at line 383 of file Bitboard.hpp.

◆ operator<<() [4/6]

auto operator<< ( const Bitboard & board,
size_t num ) -> Bitboard
related

Returns a copy of the bitboard with a binary shift left applied.

Definition at line 383 of file Bitboard.hpp.

◆ operator<<() [5/6]

auto operator<< ( const Bitboard & board,
size_t num ) -> Bitboard
related

Returns a copy of the bitboard with a binary shift left applied.

Definition at line 383 of file Bitboard.hpp.

◆ operator<<() [6/6]

auto operator<< ( const Bitboard & board,
size_t num ) -> Bitboard
related

Returns a copy of the bitboard with a binary shift left applied.

Definition at line 383 of file Bitboard.hpp.

◆ operator<=>()

auto operator<=> ( const Square & first,
const Square & second ) -> std::strong_ordering
related

Orders the two squares based on their bitboard indices.

Definition at line 130 of file Square.hpp.

◆ operator>>() [1/6]

auto operator>> ( const Bitboard & board,
size_t num ) -> Bitboard
related

Returns a copy of the bitboard with a binary shift right applied.

Definition at line 390 of file Bitboard.hpp.

◆ operator>>() [2/6]

auto operator>> ( const Bitboard & board,
size_t num ) -> Bitboard
related

Returns a copy of the bitboard with a binary shift right applied.

Definition at line 390 of file Bitboard.hpp.

◆ operator>>() [3/6]

auto operator>> ( const Bitboard & board,
size_t num ) -> Bitboard
related

Returns a copy of the bitboard with a binary shift right applied.

Definition at line 390 of file Bitboard.hpp.

◆ operator>>() [4/6]

auto operator>> ( const Bitboard & board,
size_t num ) -> Bitboard
related

Returns a copy of the bitboard with a binary shift right applied.

Definition at line 390 of file Bitboard.hpp.

◆ operator>>() [5/6]

auto operator>> ( const Bitboard & board,
size_t num ) -> Bitboard
related

Returns a copy of the bitboard with a binary shift right applied.

Definition at line 390 of file Bitboard.hpp.

◆ operator>>() [6/6]

auto operator>> ( const Bitboard & board,
size_t num ) -> Bitboard
related

Returns a copy of the bitboard with a binary shift right applied.

Definition at line 390 of file Bitboard.hpp.

◆ operator^() [1/6]

auto operator^ ( const Bitboard & lhs,
const Bitboard & rhs ) -> Bitboard
related

Returns the binary XOR of two bitboards.

Definition at line 376 of file Bitboard.hpp.

◆ operator^() [2/6]

auto operator^ ( const Bitboard & lhs,
const Bitboard & rhs ) -> Bitboard
related

Returns the binary XOR of two bitboards.

Definition at line 376 of file Bitboard.hpp.

◆ operator^() [3/6]

auto operator^ ( const Bitboard & lhs,
const Bitboard & rhs ) -> Bitboard
related

Returns the binary XOR of two bitboards.

Definition at line 376 of file Bitboard.hpp.

◆ operator^() [4/6]

auto operator^ ( const Bitboard & lhs,
const Bitboard & rhs ) -> Bitboard
related

Returns the binary XOR of two bitboards.

Definition at line 376 of file Bitboard.hpp.

◆ operator^() [5/6]

auto operator^ ( const Bitboard & lhs,
const Bitboard & rhs ) -> Bitboard
related

Returns the binary XOR of two bitboards.

Definition at line 376 of file Bitboard.hpp.

◆ operator^() [6/6]

auto operator^ ( const Bitboard & lhs,
const Bitboard & rhs ) -> Bitboard
related

Returns the binary XOR of two bitboards.

Definition at line 376 of file Bitboard.hpp.

◆ operator|() [1/6]

auto operator| ( const Bitboard & lhs,
const Bitboard & rhs ) -> Bitboard
related

Returns the binary OR of two bitboards.

Definition at line 369 of file Bitboard.hpp.

◆ operator|() [2/6]

auto operator| ( const Bitboard & lhs,
const Bitboard & rhs ) -> Bitboard
related

Returns the binary OR of two bitboards.

Definition at line 369 of file Bitboard.hpp.

◆ operator|() [3/6]

auto operator| ( const Bitboard & lhs,
const Bitboard & rhs ) -> Bitboard
related

Returns the binary OR of two bitboards.

Definition at line 369 of file Bitboard.hpp.

◆ operator|() [4/6]

auto operator| ( const Bitboard & lhs,
const Bitboard & rhs ) -> Bitboard
related

Returns the binary OR of two bitboards.

Definition at line 369 of file Bitboard.hpp.

◆ operator|() [5/6]

auto operator| ( const Bitboard & lhs,
const Bitboard & rhs ) -> Bitboard
related

Returns the binary OR of two bitboards.

Definition at line 369 of file Bitboard.hpp.

◆ operator|() [6/6]

auto operator| ( const Bitboard & lhs,
const Bitboard & rhs ) -> Bitboard
related

Returns the binary OR of two bitboards.

Definition at line 369 of file Bitboard.hpp.

◆ pawn_backward()

template<Color Side>
auto chess::board::shifts::pawn_backward ( Bitboard board) -> Bitboard
nodiscardconstexprnoexcept

Shifts all pawn positions in the starting bitboard backwards, from the given side's perspective.

Definition at line 171 of file Shifts.hpp.

◆ pawn_capture_east()

template<Color Side>
auto chess::board::shifts::pawn_capture_east ( Bitboard board) -> Bitboard
nodiscardconstexprnoexcept

Shifts all bits in the given bitboard to the east capturing direction for the given side.

Definition at line 180 of file Shifts.hpp.

◆ pawn_capture_west()

template<Color Side>
auto chess::board::shifts::pawn_capture_west ( Bitboard board) -> Bitboard
nodiscardconstexprnoexcept

Shifts all bits in the given bitboard to the west capturing direction for the given side.

Definition at line 198 of file Shifts.hpp.

◆ pawn_forward()

template<Color Side>
auto chess::board::shifts::pawn_forward ( Bitboard board) -> Bitboard
nodiscardconstexprnoexcept

Shifts all pawn positions in the starting bitboard forward, from the given side's perspective.

Definition at line 162 of file Shifts.hpp.

◆ pawn_front()

template<Color Side>
auto chess::board::fills::pawn_front ( Bitboard starting) -> Bitboard
nodiscardconstexprnoexcept

Performs a pawn front-fill from the given starting position.

Definition at line 234 of file Fills.hpp.

◆ pawn_inv_capture_east()

template<Color Side>
auto chess::board::shifts::pawn_inv_capture_east ( Bitboard board) -> Bitboard
nodiscardconstexprnoexcept

The inverse operation of pawn_capture_east(). Given a set of target squares, this function returns the set of squares that pawns must start from in order to reach the target squares by capturing east.

Definition at line 189 of file Shifts.hpp.

◆ pawn_inv_capture_west()

template<Color Side>
auto chess::board::shifts::pawn_inv_capture_west ( Bitboard board) -> Bitboard
nodiscardconstexprnoexcept

The inverse operation of pawn_capture_west(). Given a set of target squares, this function returns the set of squares that pawns must start from in order to reach the target squares by capturing west.

Definition at line 207 of file Shifts.hpp.

◆ pawn_rear()

template<Color Side>
auto chess::board::fills::pawn_rear ( Bitboard starting) -> Bitboard
nodiscardconstexprnoexcept

Performs a pawn rear-fill from the given starting position.

Definition at line 243 of file Fills.hpp.

◆ prev_pawn_rank()

template<Color Side>
auto chess::board::prev_pawn_rank ( Rank rank) -> Rank
nodiscardconstexprnoexcept

Returns the previous pawn rank, from the given side's perspective.

Definition at line 153 of file Rank.hpp.

◆ print_ascii() [1/6]

auto print_ascii ( Bitboard board) -> std::string
related

Creates an ASCII representation of the given bitboard. The returned string is meant to be interpreted visually by a human, probably for debugging purposes. The bitboard is drawn as a simple set of cells separated by | characters. Occupied squares have an x placed in them.

◆ print_ascii() [2/6]

auto print_ascii ( Bitboard board) -> std::string
related

Creates an ASCII representation of the given bitboard. The returned string is meant to be interpreted visually by a human, probably for debugging purposes. The bitboard is drawn as a simple set of cells separated by | characters. Occupied squares have an x placed in them.

◆ print_ascii() [3/6]

auto print_ascii ( Bitboard board) -> std::string
related

Creates an ASCII representation of the given bitboard. The returned string is meant to be interpreted visually by a human, probably for debugging purposes. The bitboard is drawn as a simple set of cells separated by | characters. Occupied squares have an x placed in them.

◆ print_ascii() [4/6]

auto print_ascii ( Bitboard board) -> std::string
related

Creates an ASCII representation of the given bitboard. The returned string is meant to be interpreted visually by a human, probably for debugging purposes. The bitboard is drawn as a simple set of cells separated by | characters. Occupied squares have an x placed in them.

◆ print_ascii() [5/6]

auto print_ascii ( Bitboard board) -> std::string
related

Creates an ASCII representation of the given bitboard. The returned string is meant to be interpreted visually by a human, probably for debugging purposes. The bitboard is drawn as a simple set of cells separated by | characters. Occupied squares have an x placed in them.

◆ print_ascii() [6/6]

auto print_ascii ( Bitboard board) -> std::string
related

Creates an ASCII representation of the given bitboard. The returned string is meant to be interpreted visually by a human, probably for debugging purposes. The bitboard is drawn as a simple set of cells separated by | characters. Occupied squares have an x placed in them.

◆ rank()

auto chess::board::fills::rank ( Bitboard starting) -> Bitboard
nodiscardconstexprnoexcept

Performs a rank fill of the starting bitboard. For any rank in the starting bitboard with at least 1 bit set, the returned bitboard will have all bits on that rank set to 1.

Definition at line 218 of file Fills.hpp.

◆ rank_distance() [1/4]

auto rank_distance ( const Square & first,
const Square & second ) -> BitboardIndex
related

Returns as an integer the distance between the rank of the first square and the rank of the second square.

The maximum rank distance is 7.

See also
file_distance()

Definition at line 149 of file Distances.hpp.

◆ rank_distance() [2/4]

auto rank_distance ( const Square & first,
const Square & second ) -> BitboardIndex
related

Returns as an integer the distance between the rank of the first square and the rank of the second square.

The maximum rank distance is 7.

See also
file_distance()

Definition at line 149 of file Distances.hpp.

◆ rank_distance() [3/4]

auto rank_distance ( const Square & first,
const Square & second ) -> BitboardIndex
related

Returns as an integer the distance between the rank of the first square and the rank of the second square.

The maximum rank distance is 7.

See also
file_distance()

Definition at line 149 of file Distances.hpp.

◆ rank_distance() [4/4]

auto rank_distance ( const Square & first,
const Square & second ) -> BitboardIndex
related

Returns as an integer the distance between the rank of the first square and the rank of the second square.

The maximum rank distance is 7.

See also
file_distance()

Definition at line 149 of file Distances.hpp.

◆ rank_from_char()

auto chess::board::rank_from_char ( char character) -> std::expected< Rank, std::string >
inlinenodiscard

Interprets the given character as a rank.

If the input string cannot be parsed correctly, returns an explanatory error string.

See also
Rank

Definition at line 164 of file Rank.hpp.

◆ rank_to_char()

auto chess::board::rank_to_char ( Rank rank) -> char
nodiscardconstexpr

Converts the rank to its single-character representation (as an integer).

See also
Rank

Definition at line 186 of file Rank.hpp.

◆ south() [1/2]

auto chess::board::fills::south ( Bitboard starting) -> Bitboard
nodiscardconstexprnoexcept

Performs a south fill of the starting bitboard.

Definition at line 120 of file Fills.hpp.

◆ south() [2/2]

auto chess::board::shifts::south ( Bitboard board) -> Bitboard
nodiscardconstexprnoexcept

Shifts all bits in the given board south (i.e., down one rank).

Definition at line 114 of file Shifts.hpp.

◆ southeast() [1/2]

auto chess::board::fills::southeast ( Bitboard starting) -> Bitboard
nodiscardconstexprnoexcept

Performs a southeast fill of the starting bitboard.

Definition at line 171 of file Fills.hpp.

◆ southeast() [2/2]

auto chess::board::shifts::southeast ( Bitboard board) -> Bitboard
nodiscardconstexprnoexcept

Shifts all bits in the given board southeast.

Definition at line 147 of file Shifts.hpp.

◆ southwest() [1/2]

auto chess::board::fills::southwest ( Bitboard starting) -> Bitboard
nodiscardconstexprnoexcept

Performs a southwest fill of the starting bitboard.

Definition at line 199 of file Fills.hpp.

◆ southwest() [2/2]

auto chess::board::shifts::southwest ( Bitboard board) -> Bitboard
nodiscardconstexprnoexcept

Shifts all bits in the given board southwest.

Definition at line 154 of file Shifts.hpp.

◆ vertical()

auto chess::board::flips::vertical ( Bitboard board) -> Bitboard
nodiscardconstexprnoexcept

Returns a copy of the bitboard, mirrored vertically.

Definition at line 57 of file Flips.hpp.

◆ west() [1/2]

auto chess::board::fills::west ( Bitboard starting) -> Bitboard
nodiscardconstexprnoexcept

Performs a west fill of the starting bitboard.

Definition at line 143 of file Fills.hpp.

◆ west() [2/2]

auto chess::board::shifts::west ( Bitboard board) -> Bitboard
nodiscardconstexprnoexcept

Shifts all bits in the given board west (i.e., left one file).

Definition at line 126 of file Shifts.hpp.

Variable Documentation

◆ MAX_BITBOARD_IDX

BitboardIndex chess::board::MAX_BITBOARD_IDX = NUM_SQUARES - UINT8_C(1)
inlineconstexpr

The maximum valid bitboard bit index.

See also
NUM_SQUARES

Definition at line 46 of file BitboardIndex.hpp.

◆ NUM_SQUARES

BitboardIndex chess::board::NUM_SQUARES = UINT8_C(64)
inlineconstexpr

The number of squares on a chessboard.

See also
MAX_BITBOARD_IDX

Definition at line 39 of file BitboardIndex.hpp.