|
BenBot 1.7.5
A chess engine
|
#include <libchess/board/Bitboard.hpp>
Public Types | |
| using | Integer = std::uint64_t |
Public Member Functions | |
| constexpr | Bitboard () noexcept=default |
| constexpr | Bitboard (Integer val) noexcept |
| constexpr auto | operator== (const Bitboard &) const noexcept -> bool=default |
| constexpr auto | to_int () const noexcept -> Integer |
Observers | |
| constexpr auto | any () const noexcept -> bool |
| constexpr auto | none () const noexcept -> bool |
| constexpr auto | count () const noexcept -> size_t |
| constexpr auto | test (const Square square) const noexcept -> bool |
| constexpr auto | test (BitboardIndex index) const noexcept -> bool |
| constexpr auto | first () const noexcept -> BitboardIndex |
| constexpr auto | last () const noexcept -> BitboardIndex |
Modifiers | |
| constexpr void | set (const Square square) noexcept |
| constexpr void | set (BitboardIndex index) noexcept |
| constexpr void | unset (const Square square) noexcept |
| constexpr void | unset (BitboardIndex index) noexcept |
| constexpr void | clear () noexcept |
Iteration | |
| constexpr auto | indices () const noexcept |
| constexpr auto | squares () const noexcept |
| constexpr auto | subboards () const noexcept |
Binary operations | |
| constexpr auto | inverse () const noexcept -> Bitboard |
| constexpr auto | operator&= (const Bitboard &other) noexcept -> Bitboard & |
| constexpr auto | operator|= (const Bitboard &other) noexcept -> Bitboard & |
| constexpr auto | operator^= (const Bitboard &other) noexcept -> Bitboard & |
| constexpr auto | operator<<= (size_t num) noexcept -> Bitboard & |
| constexpr auto | operator>>= (size_t num) noexcept -> Bitboard & |
Static Public Member Functions | |
| static constexpr auto | from_square (Square square) noexcept -> Bitboard |
Related Symbols | |
(Note that these are not member symbols.) | |
| consteval auto | operator""_bb (const unsigned long long value) 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 |
This class is similar to std::bitset, in that it is a simple collection of 64 bits, but it includes some convenience methods specific to usage as a bitboard.
Each bit represents a square of the chessboard; the bit is 1 if there is a piece there, and 0 if the square is empty.
Mapping ranks/files to indices of bits within a bitboard is handled by the Square class.
Definition at line 48 of file Bitboard.hpp.
| using chess::board::Bitboard::Integer = std::uint64_t |
Unsigned integer type used for bitboard representation.
Definition at line 50 of file Bitboard.hpp.
|
constexprdefaultnoexcept |
Constructs an empty bitboard.
|
explicitconstexprnoexcept |
Constructs a bitboard from an integer representation.
Definition at line 274 of file Bitboard.hpp.
|
inlinenodiscardconstexprnoexcept |
Returns true if any of the bits are set.
Definition at line 67 of file Bitboard.hpp.
|
inlineconstexprnoexcept |
Resets all bits to 0.
Definition at line 117 of file Bitboard.hpp.
|
inlinenodiscardconstexprnoexcept |
Returns the number of bits that are set.
Definition at line 73 of file Bitboard.hpp.
|
nodiscardconstexprnoexcept |
Returns the index of the first set bit. This operation may also be known as "bitscan forward". Returns 64 if all bits are 0.
Definition at line 309 of file Bitboard.hpp.
|
staticnodiscardconstexprnoexcept |
Returns a bitboard with only a single bit set.
Definition at line 279 of file Bitboard.hpp.
|
nodiscardconstexprnoexcept |
Returns an iterable range of indices representing the 1 bits in this bitboard. The returned indices should be iterated by value, not by reference; i.e.:
Definition at line 452 of file Bitboard.hpp.
|
nodiscardconstexprnoexcept |
Returns a copy of this bitboard with all bits flipped (binary NOT).
Definition at line 357 of file Bitboard.hpp.
|
nodiscardconstexprnoexcept |
Returns the index of the last set bit. This operation may also be known as "bitscan reverse". Returns 64 if all bits are 0.
Definition at line 315 of file Bitboard.hpp.
|
inlinenodiscardconstexprnoexcept |
Returns true if none of the bits are set.
Definition at line 70 of file Bitboard.hpp.
Performs binary AND with another bitboard.
Definition at line 327 of file Bitboard.hpp.
|
constexprnoexcept |
Performs binary shift left (towards higher index positions). Zeroes are shifted in, and bits that would go to an index out of range are dropped.
Definition at line 345 of file Bitboard.hpp.
|
nodiscardconstexprdefaultnoexcept |
Returns true if the two bitboards have all the same bits set.
|
constexprnoexcept |
Performs binary shift right (towards lower index positions). Zeroes are shifted in, and bits that would go to an index out of range are dropped.
Definition at line 351 of file Bitboard.hpp.
Performs binary XOR with another bitboard.
Definition at line 339 of file Bitboard.hpp.
Performs binary OR with another bitboard.
Definition at line 333 of file Bitboard.hpp.
|
constexprnoexcept |
Sets the given square's bit to 1. This method asserts if the given index is greater than 63.
Definition at line 293 of file Bitboard.hpp.
|
inlineconstexprnoexcept |
Sets the given square's bit to 1.
Definition at line 101 of file Bitboard.hpp.
|
nodiscardconstexprnoexcept |
Returns an iterable range of Square objects representing the 1 bits in this bitboard. The Square objects should be iterated by value, not by reference; i.e.:
Definition at line 461 of file Bitboard.hpp.
|
nodiscardconstexprnoexcept |
Returns an iterable range of Bitboard objects that each have a single bit set, each representing the 1 bits in this bitboard. This is a transformation of a single bitboard with up to 64 bits set into a set of up to 64 bitboards each with a single bit set.
The Bitboard objects should be iterated by value, not by reference; i.e.:
Definition at line 467 of file Bitboard.hpp.
|
nodiscardconstexprnoexcept |
Returns true if there is a piece on the given square. This method asserts if the given index is greater than 63.
Definition at line 284 of file Bitboard.hpp.
|
inlinenodiscardconstexprnoexcept |
Returns true if there is a piece on the given square.
Definition at line 76 of file Bitboard.hpp.
|
inlinenodiscardconstexprnoexcept |
Converts this bitboard to its integer representation.
Definition at line 122 of file Bitboard.hpp.
|
constexprnoexcept |
Sets the given square's bit to 0. This method asserts if the given index is greater than 63.
Definition at line 300 of file Bitboard.hpp.
|
inlineconstexprnoexcept |
Sets the given square's bit to 0.
Definition at line 109 of file Bitboard.hpp.