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

Files

file  Algebraic.hpp
file  EPD.hpp
file  FEN.hpp
file  ICCF.hpp
file  MoveFormats.hpp
file  PGN.hpp
file  UCI.hpp

Namespaces

namespace  chess
namespace  chess::notation

Classes

struct  chess::notation::EPDPosition
struct  chess::notation::GameRecord
struct  chess::notation::GameRecord::Move

Enumerations

enum class  chess::notation::MoveFormat : std::uint_least8_t { chess::notation::MoveFormat::Algebraic , chess::notation::MoveFormat::ICCF , chess::notation::MoveFormat::UCI }
enum class  chess::notation::NAG : std::uint_least8_t {
  chess::notation::NAG::Null = 0 , chess::notation::NAG::Good = 1 , chess::notation::NAG::Brilliant = 3 , chess::notation::NAG::Inaccuracy = 2 ,
  chess::notation::NAG::Blunder = 4 , chess::notation::NAG::Interesting = 5 , chess::notation::NAG::Dubious = 6 , chess::notation::NAG::Forced = 7 ,
  chess::notation::NAG::Drawish = 10 , chess::notation::NAG::Unclear = 13 , chess::notation::NAG::WhiteSlightAdvantage = 14 , chess::notation::NAG::WhiteModerateAdvantage = 16 ,
  chess::notation::NAG::WhiteDecisiveAdvantage = 18 , chess::notation::NAG::WhiteCrushingAdvantage = 20 , chess::notation::NAG::BlackSlightAdvantage = 15 , chess::notation::NAG::BlackModerateAdvantage = 17 ,
  chess::notation::NAG::BlackDecisiveAdvantage = 19 , chess::notation::NAG::BlackCrushingAdvantage = 21 , chess::notation::NAG::WhiteZugzwang = 22 , chess::notation::NAG::WhiteInitiative = 36 ,
  chess::notation::NAG::BlackInitiative = 37
}

Functions

auto chess::notation::format_move (const MoveFormat format, const Position &position, const Move move) -> std::string
auto chess::notation::from_alg (const Position &position, std::string_view text) -> std::expected< Move, std::string >
auto from_epd (std::string_view epdString) -> std::expected< EPDPosition, string >
auto chess::notation::from_fen (std::string_view fenString) -> std::expected< Position, std::string >
auto chess::notation::from_iccf (const Position &position, std::string_view text) -> std::expected< Move, std::string >
auto from_pgn (std::string_view pgnText) -> std::expected< GameRecord, std::string_view >
auto chess::notation::from_uci (const Position &position, std::string_view text) -> std::expected< Move, std::string >
auto parse_all_epds (std::string_view fileContent) -> std::vector< EPDPosition >
auto parse_all_pgns (std::string_view fileContent) -> std::vector< GameRecord >
auto chess::notation::to_alg (const Position &position, Move move) -> std::string
auto to_epd (const EPDPosition &pos) -> string
auto chess::notation::to_fen (const Position &position, bool alwaysWriteEPSqare=true) -> std::string
auto chess::notation::to_iccf (Move move) -> std::string
auto to_pgn (const GameRecord &game, bool useBlockComments=true) -> string
auto chess::notation::to_uci (Move move) -> std::string

Detailed Description

Functions for working with various types of chess game notation.

Enumeration Type Documentation

◆ MoveFormat

enum class chess::notation::MoveFormat : std::uint_least8_t
strong

This enum describes the supported notation formats for moves.

See also
format_move()
Enumerator
Algebraic 

Algebraic notation.

ICCF 

ICCF numeric notation.

UCI 

UCI notation.

Definition at line 40 of file MoveFormats.hpp.

◆ NAG

enum class chess::notation::NAG : std::uint_least8_t
strong

PGN [1] NAG glyphs are represented by their numeric codes. This enumeration lists many of the standard NAGs (but not all of them).

Enumerator
Null 

A null annotation. Provided for usage as a placeholder value; should not appear in PGN files and has no typographic representation.

Good 

A good move, typically displayed as !.

Brilliant 

A brilliant move, typically displayed as !!.

Inaccuracy 

A mistake, typically displayed as ?.

Blunder 

A blunder, typically displayed as ??.

Interesting 

A speculative or interesting move, typically displayed as !?.

Dubious 

A questionable or dubious move, typically displayed as ?!.

Forced 

A forced or only move, typically displayed as a white square.

Drawish 

Indicates that the position is drawish or double-sided, typically displayed as =.

Unclear 

Indicates that the position is unclear, typically displayed as an infinity symbol.

WhiteSlightAdvantage 

Indicates that white has a slight advantage in this position.

WhiteModerateAdvantage 

Indicates that white has a moderate advantage in this position.

WhiteDecisiveAdvantage 

Indicates that white has a decisive advantage in this position.

WhiteCrushingAdvantage 

Indicates that white has a crushing advantage in this position (black should resign).

BlackSlightAdvantage 

Indicates that black has a slight advantage in this position.

BlackModerateAdvantage 

Indicates that black has a moderate advantage in this position.

BlackDecisiveAdvantage 

Indicates that black has a decisive advantage in this position.

BlackCrushingAdvantage 

Indicates that black has a crushing advantage in this position (white should resign).

WhiteZugzwang 

Indicates that white is in Zugzwang in this position.

WhiteInitiative 

Indicates that white has the initiative in this position.

BlackInitiative 

Indicates that black has the initiative in this position.

Definition at line 43 of file PGN.hpp.

Function Documentation

◆ format_move()

auto chess::notation::format_move ( const MoveFormat format,
const Position & position,
const Move move ) -> std::string
inlinenodiscard

Prints a move using the given notation format.

See also
MoveFormat

Definition at line 50 of file MoveFormats.hpp.

◆ from_alg()

auto chess::notation::from_alg ( const Position & position,
std::string_view text ) -> std::expected< Move, std::string >
nodiscard

Creates a move from a string in algebraic notation, such as "Nd4", "e8=Q", "O-O-O", etc.

This function expects Standard Algebraic Notation (SAN) strings.

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

See also
to_alg()

◆ from_epd()

auto from_epd ( std::string_view epdString) -> std::expected< EPDPosition, string >
related

Parses an EPD string.

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

See also
parse_all_epds()

◆ from_fen()

auto chess::notation::from_fen ( std::string_view fenString) -> std::expected< Position, std::string >
nodiscard

Returns a Position object encoding the given FEN string.

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

See also
to_fen()

◆ from_iccf()

auto chess::notation::from_iccf ( const Position & position,
std::string_view text ) -> std::expected< Move, std::string >
nodiscard

Parses the ICCF-format [2] notation string into a Move object. The current position is used to determine the type of the moved piece.

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

See also
to_iccf()

◆ from_pgn()

auto from_pgn ( std::string_view pgnText) -> std::expected< GameRecord, std::string_view >
related

Parses the text of a PGN [1] file into a GameRecord object.

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

See also
parse_all_pgns()

◆ from_uci()

auto chess::notation::from_uci ( const Position & position,
std::string_view text ) -> std::expected< Move, std::string >
nodiscard

Parses the UCI-format [3] algebraic notation string into a Move object. The current position is used to determine the type of the moved piece.

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

See also
from_uci()

◆ parse_all_epds()

auto parse_all_epds ( std::string_view fileContent) -> std::vector< EPDPosition >
related

Parses all EPDs in a string containing one EPD per line.

See also
from_epd()

◆ parse_all_pgns()

auto parse_all_pgns ( std::string_view fileContent) -> std::vector< GameRecord >
related

Parses a text file that may contain 0 or more PGNs into a list of GameRecord objects. PGNs in the fileContent should be separated by at least 1 newline character. If parsing any of the PGNs fails, they will simply be omitted from the list, and any exceptions raised by parsing will not be propagated.

See also
from_pgn()

◆ to_alg()

auto chess::notation::to_alg ( const Position & position,
Move move ) -> std::string
nodiscard

Returns the algebraic notation for the given Move object. This function creates Standard Algebraic Notation (SAN) strings. The current state of the position is used to determine whether the move is a capture, and the pieces of the side to move are used for disambiguation if necessary.

See also
from_alg()

◆ to_epd()

auto to_epd ( const EPDPosition & pos) -> string
related

Writes a position to an EPD string.

◆ to_fen()

auto chess::notation::to_fen ( const Position & position,
bool alwaysWriteEPSqare = true ) -> std::string
nodiscard

Returns the FEN representation of the given position.

Parameters
positionThe position to serialize as a FEN string.
alwaysWriteEPSqareIf true, the en passant square will be written any time the last move was a pawn double-advance; if false, the en passant square will only be written if the opponent has any pawns capable of capturing en passant (as in X-FEN).
See also
from_fen()

◆ to_iccf()

auto chess::notation::to_iccf ( Move move) -> std::string
nodiscard

Returns the ICCF-format [2] notation for the given Move object.

See also
from_iccf()

◆ to_pgn()

auto to_pgn ( const GameRecord & game,
bool useBlockComments = true ) -> string
related

Creates a PGN [1] string from the given game record.

Parameters
gameThe game record to serialize.
useBlockCommentsIf true (the default), move comment strings will be written using the {<comment>} syntax. If false, comments will be written using ; <comment>\n.

◆ to_uci()

auto chess::notation::to_uci ( Move move) -> std::string
nodiscard

Returns the UCI-format [3] algebraic notation for the given Move object.

See also
from_uci()