BenBot 1.7.5
A chess engine
Loading...
Searching...
No Matches
chess::moves Namespace Reference

Namespaces

namespace  magics
namespace  patterns
namespace  pseudo_legal

Classes

struct  Bitboard
struct  Move
struct  PerftResult
struct  Pieces
struct  Position
struct  Square

Typedefs

using MaybePieceType = std::optional<PieceType>
using PieceType = pieces::Type

Enumerations

enum class  Color
enum class  Color
enum class  File
enum class  Rank

Functions

constexpr auto castle_kingside (const Color color) noexcept -> Move
constexpr auto castle_queenside (const Color color) noexcept -> Move
template<Color Side>
constexpr auto num_squares_attacked (const Pieces &pieces, Bitboard targetSquares, Bitboard enemyPieces, bool includeKing=true) noexcept -> size_t
constexpr auto operator<=> (const Move &first, const Move &second) noexcept -> std::strong_ordering
template<bool IsRoot>
auto perft (const size_t depth, const game::Position &startingPosition) -> PerftResult
template<bool IsRoot = true>
auto perft (size_t depth, const game::Position &startingPosition) -> PerftResult
constexpr auto promotion (const File file, const Color color, const PieceType promotedType) noexcept -> Move
template<Color Side>
constexpr auto squares_attacked (const Pieces &pieces, Bitboard targetSquares, Bitboard enemyPieces) noexcept -> bool
using MoveList = beman::inplace_vector::inplace_vector<Move, MAX_MOVES>
constexpr auto MAX_MOVES = 256uz
template<bool CapturesOnly = false>
void generate (const Position &position, std::output_iterator< Move > auto outputIt)
template<bool CapturesOnly = false>
auto generate (const Position &position) -> MoveList
template<bool CapturesOnly = false>
void generate_for (const Position &position, PieceType piece, std::output_iterator< Move > auto outputIt)
template<bool CapturesOnly = false>
auto generate_for (const Position &position, PieceType piece) -> MoveList
auto any_legal_moves (const Position &position) -> bool

Detailed Description

This namespace contains classes for modeling moves.

Typedef Documentation

◆ MaybePieceType

using chess::moves::MaybePieceType = std::optional<PieceType>

Definition at line 55 of file Move.hpp.

◆ MoveList

using chess::moves::MoveList = beman::inplace_vector::inplace_vector<Move, MAX_MOVES>

A stack-allocated array of moves.

See also
MAX_MOVES

Definition at line 63 of file MoveGen.hpp.

◆ PieceType

Definition at line 54 of file Move.hpp.

Enumeration Type Documentation

◆ Color [1/2]

enum class chess::pieces::Color : std::uint_fast8_t
strong

This enum identifies the side to move.

Definition at line 29 of file Colors.hpp.

◆ Color [2/2]

enum class chess::pieces::Color : std::uint_fast8_t
strong

This enum identifies the side to move.

Definition at line 29 of file Colors.hpp.

◆ File

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

This enum describes the files of the chess board.

See also
Rank

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

Definition at line 40 of file Rank.hpp.

Function Documentation

◆ any_legal_moves()

auto chess::moves::any_legal_moves ( const Position & position) -> bool
inlinenodiscard

Returns true if the side to move has any legal moves in the given position.

Definition at line 777 of file MoveGen.hpp.

◆ castle_kingside()

auto chess::moves::castle_kingside ( const Color color) -> Move
related

Definition at line 304 of file Move.hpp.

◆ castle_queenside()

auto chess::moves::castle_queenside ( const Color color) -> Move
related

Definition at line 315 of file Move.hpp.

◆ generate() [1/2]

template<bool CapturesOnly = false>
auto chess::moves::generate ( const Position & position) -> MoveList
nodiscard

Generates a list of all legal moves for the side to move in the given position. If the side to move is in checkmate or stalemate, this returns an empty list. The list of moves is not sorted in any particular manner.

See also
generate_for()

Definition at line 745 of file MoveGen.hpp.

◆ generate() [2/2]

template<bool CapturesOnly = false>
void chess::moves::generate ( const Position & position,
std::output_iterator< Move > auto outputIt )

Generates a list of all legal moves for the side to move in the given position. The list of moves is not sorted in any particular manner.

See also
generate_for()

Definition at line 734 of file MoveGen.hpp.

◆ generate_for() [1/2]

template<bool CapturesOnly = false>
auto chess::moves::generate_for ( const Position & position,
PieceType piece ) -> MoveList
nodiscard

Generates a list of all legal moves for only the given piece type in the given position.

Generating King moves will include castling. Generating pawn moves will include all pushes, double pushes, captures, promotions, and en passant captures.

See also
generate()

Definition at line 766 of file MoveGen.hpp.

◆ generate_for() [2/2]

template<bool CapturesOnly = false>
void chess::moves::generate_for ( const Position & position,
PieceType piece,
std::output_iterator< Move > auto outputIt )

Generates a list of all legal moves for only the given piece type in the given position.

Generating King moves will include castling. Generating pawn moves will include all pushes, double pushes, captures, promotions, and en passant captures.

See also
generate()

Definition at line 755 of file MoveGen.hpp.

◆ perft()

template<bool IsRoot>
auto chess::moves::perft ( const size_t depth,
const game::Position & startingPosition ) -> PerftResult
related

Definition at line 119 of file Perft.hpp.

◆ promotion()

auto chess::moves::promotion ( const File file,
const Color color,
const PieceType promotedType ) -> Move
related

Definition at line 326 of file Move.hpp.