BenBot 1.7.5
A chess engine
Loading...
Searching...
No Matches
Piece types
Collaboration diagram for Piece types:

Topics

 UTF8 encoded piece symbols

Files

file  Colors.hpp
file  PieceTypes.hpp

Namespaces

namespace  chess
namespace  chess::pieces

Classes

struct  std::formatter< chess::pieces::Type >

Enumerations

enum class  chess::pieces::Color : std::uint_fast8_t { chess::pieces::Color::Black , chess::pieces::Color::White }
enum class  chess::pieces::Type : std::uint_fast8_t {
  chess::pieces::Type::Pawn , chess::pieces::Type::Knight , chess::pieces::Type::Bishop , chess::pieces::Type::Rook ,
  chess::pieces::Type::Queen , chess::pieces::Type::King
}

Functions

auto chess::pieces::from_string (std::string_view text) -> std::expected< Type, std::string >
template<Color Side>
constexpr auto chess::pieces::other_side () noexcept -> Color
constexpr auto chess::pieces::to_char (Type type, bool uppercase=true) -> char

Detailed Description

Classes for working with the various chess piece types, and associated information.

Enumeration Type Documentation

◆ Color

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

This enum identifies the side to move.

Enumerator
Black 

The Black player.

White 

The White player.

Definition at line 29 of file Colors.hpp.

◆ Type

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

This enum identifies the different types of pieces.

See also
utf8 values
Enumerator
Pawn 

A White pawn.

Knight 

A knight.

Bishop 

A bishop.

Rook 

A rook.

Queen 

A queen.

King 

A king.

Definition at line 48 of file PieceTypes.hpp.

Function Documentation

◆ from_string()

auto chess::pieces::from_string ( std::string_view text) -> std::expected< Type, std::string >
inlinenodiscard

Parses a piece type from a string. This function recognizes single-letter abbreviations (such as N for knight, etc.), or full piece names.

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

Definition at line 133 of file PieceTypes.hpp.

◆ other_side()

template<Color Side>
auto chess::pieces::other_side ( ) -> Color
nodiscardconstexprnoexcept

Returns the opposite color.

See also
Color

Definition at line 40 of file Colors.hpp.

◆ to_char()

auto chess::pieces::to_char ( Type type,
bool uppercase = true ) -> char
nodiscardconstexpr

Converts the given piece type to its single-character representation.

Definition at line 120 of file PieceTypes.hpp.