HooverChessUtils_PgnReader 0.9.0
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
hoover_chess_utils::pgn_reader::Move Class Reference

A legal move. Important: see the note! More...

#include <chessboard.h>

Public Member Functions

constexpr Move () noexcept=default
 Default constructor (null move)
 
constexpr Move (Square src, Square dst, MoveTypeAndPromotion typeAndPromo) noexcept
 Constructor.
 
constexpr Move (const Move &) noexcept=default
 Constructor (copy)
 
constexpr Move (Move &&) noexcept=default
 Constructor (move)
 
Moveoperator= (const Move &) noexcept=default
 Assignment.
 
Moveoperator= (Move &&) noexcept=default
 Move assignment.
 
constexpr Move (const CompactMove &m) noexcept
 Constructs a Move from a CompactMove
 
 ~Move () noexcept=default
 Destructor.
 
constexpr Square getSrc () const noexcept
 Returns move source square.
 
constexpr Square getDst () const noexcept
 Returns move destination square.
 
constexpr MoveTypeAndPromotion getTypeAndPromotion () const noexcept
 Returns move type and promotion piece.
 
constexpr bool isRegularMove () const noexcept
 Checks whether a move type is regular.
 
constexpr bool isEnPassantMove () const noexcept
 Checks whether the move type is en-passant pawn capture.
 
constexpr bool isPromotionMove () const noexcept
 Checks whether the move type is a pawn promotion.
 
constexpr bool isCastlingMove () const noexcept
 Checks whether a move type is a castling move.
 
constexpr Piece getPromotionPiece () const noexcept
 Returns promotion piece of a promotion move.
 
constexpr bool isIllegal () const noexcept
 Checks whether the move type is illegal.
 
constexpr std::uint_fast16_t getEncodedValue () const noexcept
 Returns raw encoded value. Usually only used in debugging.
 
constexpr bool operator== (const Move &o) const noexcept
 Comparator (equality)
 

Static Public Member Functions

static constexpr Move illegalNoMove () noexcept
 Token for illegal move: no moves generated.
 
static constexpr Move illegalAmbiguousMove () noexcept
 Token for illegal move: ambiguous move generation.
 

Static Private Member Functions

static constexpr std::uint_fast16_t getMoveTypeAndPromotionMask (MoveTypeAndPromotionUnderlyingType mask) noexcept
 

Private Attributes

std::uint_fast16_t m_encoded { }
 Encoded move.
 

Detailed Description

A legal move. Important: see the note!

The move object is intended to be passed to functions as a fast type. The underlying representation is std::uint_fast16_t, which may be larger than 16 bits depending on the target.

When storing moves to memory (e.g., move lists), consider using CompactMove, instead.

Note
Always use one of the move generators to construct a legal move. ChessBoard::doMove() assumes that the move is legal and it does not perform any legality checks of its own.

Constructor & Destructor Documentation

◆ Move() [1/5]

constexpr hoover_chess_utils::pgn_reader::Move::Move ( )
constexprdefaultnoexcept

Default constructor (null move)

◆ Move() [2/5]

constexpr hoover_chess_utils::pgn_reader::Move::Move ( Square  src,
Square  dst,
MoveTypeAndPromotion  typeAndPromo 
)
inlineconstexprnoexcept

Constructor.

Parameters
[in]srcMove source square. Must be a valid square.
[in]dstMove destination square. Must be a valid square.
[in]typeAndPromoMove type and promotion piece

See MoveTypeAndPromotion on how src and dst are used for en-passant and castling move types.

Note
See MoveTypeAndPromotion::ILLEGAL on constraints for illegal moves.

◆ Move() [3/5]

constexpr hoover_chess_utils::pgn_reader::Move::Move ( const Move )
constexprdefaultnoexcept

Constructor (copy)

◆ Move() [4/5]

constexpr hoover_chess_utils::pgn_reader::Move::Move ( Move &&  )
constexprdefaultnoexcept

Constructor (move)

◆ Move() [5/5]

constexpr hoover_chess_utils::pgn_reader::Move::Move ( const CompactMove m)
inlineconstexprnoexcept

Constructs a Move from a CompactMove

Parameters
[in]mCompact move

◆ ~Move()

hoover_chess_utils::pgn_reader::Move::~Move ( )
defaultnoexcept

Destructor.

Member Function Documentation

◆ getDst()

constexpr Square hoover_chess_utils::pgn_reader::Move::getDst ( ) const
inlineconstexprnoexcept

Returns move destination square.

See MoveTypeAndPromotion on how src and dst are used for en-passant and castling move types.

◆ getEncodedValue()

constexpr std::uint_fast16_t hoover_chess_utils::pgn_reader::Move::getEncodedValue ( ) const
inlineconstexprnoexcept

Returns raw encoded value. Usually only used in debugging.

Returns
Encoded value of move

◆ getMoveTypeAndPromotionMask()

static constexpr std::uint_fast16_t hoover_chess_utils::pgn_reader::Move::getMoveTypeAndPromotionMask ( MoveTypeAndPromotionUnderlyingType  mask)
inlinestaticconstexprprivatenoexcept

◆ getPromotionPiece()

constexpr Piece hoover_chess_utils::pgn_reader::Move::getPromotionPiece ( ) const
inlineconstexprnoexcept

Returns promotion piece of a promotion move.

◆ getSrc()

constexpr Square hoover_chess_utils::pgn_reader::Move::getSrc ( ) const
inlineconstexprnoexcept

Returns move source square.

See MoveTypeAndPromotion on how src and dst are used for en-passant and castling move types.

◆ getTypeAndPromotion()

constexpr MoveTypeAndPromotion hoover_chess_utils::pgn_reader::Move::getTypeAndPromotion ( ) const
inlineconstexprnoexcept

Returns move type and promotion piece.

◆ illegalAmbiguousMove()

static constexpr Move hoover_chess_utils::pgn_reader::Move::illegalAmbiguousMove ( )
inlinestaticconstexprnoexcept

Token for illegal move: ambiguous move generation.

Returns
Illegal move token: ambiguous move generation

◆ illegalNoMove()

static constexpr Move hoover_chess_utils::pgn_reader::Move::illegalNoMove ( )
inlinestaticconstexprnoexcept

Token for illegal move: no moves generated.

Returns
Illegal move token: no moves generated

◆ isCastlingMove()

constexpr bool hoover_chess_utils::pgn_reader::Move::isCastlingMove ( ) const
inlineconstexprnoexcept

Checks whether a move type is a castling move.

Returns
Whether the move type is a castling move

Pawn promotion move types are the following:

◆ isEnPassantMove()

constexpr bool hoover_chess_utils::pgn_reader::Move::isEnPassantMove ( ) const
inlineconstexprnoexcept

Checks whether the move type is en-passant pawn capture.

Returns
Whether the move type is en-passant pawn capture

En-passant pawn capture move type is the following;

◆ isIllegal()

constexpr bool hoover_chess_utils::pgn_reader::Move::isIllegal ( ) const
inlineconstexprnoexcept

Checks whether the move type is illegal.

Returns
Whether move is one of the illegal moves
Note
See MoveTypeAndPromotion::ILLEGAL on constraints for illegal moves.

◆ isPromotionMove()

constexpr bool hoover_chess_utils::pgn_reader::Move::isPromotionMove ( ) const
inlineconstexprnoexcept

Checks whether the move type is a pawn promotion.

Returns
Whether the move type is a pawn promotion move

Pawn promotion move types are the following:

◆ isRegularMove()

constexpr bool hoover_chess_utils::pgn_reader::Move::isRegularMove ( ) const
inlineconstexprnoexcept

◆ operator=() [1/2]

Move & hoover_chess_utils::pgn_reader::Move::operator= ( const Move )
defaultnoexcept

Assignment.

◆ operator=() [2/2]

Move & hoover_chess_utils::pgn_reader::Move::operator= ( Move &&  )
defaultnoexcept

Move assignment.

◆ operator==()

constexpr bool hoover_chess_utils::pgn_reader::Move::operator== ( const Move o) const
inlineconstexprnoexcept

Comparator (equality)

Parameters
[in]oAnother move
Returns
Comparison result

Member Data Documentation

◆ m_encoded

std::uint_fast16_t hoover_chess_utils::pgn_reader::Move::m_encoded { }
private

Encoded move.

Bitfield
15141312111098 76543210
Destination square Move type and promotion Source square

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