chess/algebraic_notation

This module provides functionality to generate Standard Algrebaic Notation for chess moves.

Here are some examples of SAN:

e4 “Pawn to E4”

Qxd7 “Queen takes D7”

exd3+ “E-Pawn takes D3, check”

Nac3 “Knight A2 to C3”

Formatting rules

The formatting is generated as follows:

(<standard-move> | 'O-O' | 'O-O-O')<checks>

where:

<standard-move> is defined as:

<figure><disambiguation><takes><destination><promotion>

where: (cases are processed from top to bottom)

Types

An error returned by describe.

pub type DescribeError {
  GameAlreadyOver
  ProvidedMoveIsIllegal
}

Constructors

  • GameAlreadyOver

    Tried to describe a move, which belongs to a game that is already over.

  • ProvidedMoveIsIllegal

    Tried to describe a move, which is not legal.

Values

pub fn describe(
  game game: chess.GameState,
  move move: chess.Move,
) -> Result(String, DescribeError)

Describes the given move using Standard Algebraic Notation.

See the module description for the formatting rules and examples.

game is the state before executing the move.

Errors if the game is already over, or the provided move not legal.

Search Document