BenBot 1.7.5
A chess engine
Loading...
Searching...
No Matches
chess::game::CastlingRights Struct Referencefinal

#include <libchess/game/CastlingRights.hpp>

Public Member Functions

constexpr auto either () const noexcept -> bool
constexpr void king_moved () noexcept
constexpr auto neither () const noexcept -> bool
constexpr auto operator== (const CastlingRights &) const noexcept -> bool=default
constexpr void our_move (Move move) noexcept
constexpr void rook_moved (bool isKingside) noexcept
template<Color Side>
constexpr void their_move (Move move) noexcept

Public Attributes

bool kingside { true }
bool queenside { true }

Detailed Description

This struct encapsulates one side's castling rights.

Definition at line 40 of file CastlingRights.hpp.

Member Function Documentation

◆ either()

auto chess::game::CastlingRights::either ( ) const -> bool
inlinenodiscardconstexprnoexcept

Returns true if castling either direction is possible.

Definition at line 74 of file CastlingRights.hpp.

◆ king_moved()

void chess::game::CastlingRights::king_moved ( )
constexprnoexcept

Called when the king moves. Moving the king loses castling rights for both directions.

Definition at line 97 of file CastlingRights.hpp.

◆ neither()

auto chess::game::CastlingRights::neither ( ) const -> bool
inlinenodiscardconstexprnoexcept

Returns true if neither castling direction is available.

Definition at line 77 of file CastlingRights.hpp.

◆ operator==()

auto chess::game::CastlingRights::operator== ( const CastlingRights & ) const -> bool=default
nodiscardconstexprdefaultnoexcept

Returns true if the two sets of castling rights are identical.

◆ our_move()

void chess::game::CastlingRights::our_move ( Move move)
constexprnoexcept

Call this any time a move is made by this side to update the castling rights.

Definition at line 114 of file CastlingRights.hpp.

◆ rook_moved()

void chess::game::CastlingRights::rook_moved ( bool isKingside)
constexprnoexcept

Called when a rook moves. Moving a rook loses castling rights to that side.

Parameters
isKingsideShould be true if the move's from square is on the kingside.

Definition at line 103 of file CastlingRights.hpp.

◆ their_move()

template<Color Side>
void chess::game::CastlingRights::their_move ( Move move)
constexprnoexcept

Call this any time the opponent makes a move to update the castling rights. An opponent's move can remove castling rights if they capture a rook.

Template Parameters
SideThe color that this castling rights object represents.

Definition at line 128 of file CastlingRights.hpp.

Member Data Documentation

◆ kingside

bool chess::game::CastlingRights::kingside { true }

True if kingside (or "short") castling is available.

Definition at line 42 of file CastlingRights.hpp.

◆ queenside

bool chess::game::CastlingRights::queenside { true }

True if queenside (or "long") castling is available.

Definition at line 45 of file CastlingRights.hpp.


The documentation for this struct was generated from the following file: