chess_logic v0.2.2 ChessLogic.Position

Documentation for Position.

This is the main interface to chessfold functions. It is used mainly by Game.

Link to this section Summary

Functions

Returns a list of all available moves, represented as string

Returns the tally of the position

Returns a list of pieces with square from a given position

Transforms a move to a short algebraic notation. eg. “g1f3” -> “Nf3”

Returns a new position from a fen string. Returns default position if fen is not given

Play a move. a move looks like “e2e4”

Transforms a short algebraic notation to a move. eg. “Nf3” -> “g1f3”

Link to this section Types

Link to this type color()
color() :: :black | :white
Link to this type error()
error() :: {:error, term()}
Link to this type fen()
fen() :: String.t()
Link to this type maybe_piece()
maybe_piece() :: %ChessLogic.Piece{pcolor: term(), ptype: term()} | :empty
Link to this type move()
move() :: String.t()
Link to this type position()
position() :: [[maybe_piece()]]
Link to this type t()
t() :: %ChessLogic.Position{fen: fen(), position: position()}

Link to this section Functions

Link to this function all_possible_moves(position)
all_possible_moves(t()) :: [move()]

Returns a list of all available moves, represented as string.

Link to this function get_status(position)

Returns the tally of the position.

Link to this function list_pieces_with_square(position)
list_pieces_with_square(t()) :: [term()]

Returns a list of pieces with square from a given position.

Link to this function move_to_san(position, move)
move_to_san(t(), String.t()) :: {:ok, String.t()} | error()

Transforms a move to a short algebraic notation. eg. “g1f3” -> “Nf3”.

Link to this function new(fen \\ "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1")
new(fen() | nil) :: t() | error()

Returns a new position from a fen string. Returns default position if fen is not given.

Link to this function piece_symbol(buffer, arg2, arg3, pawn, piece)
Link to this function play(position, move)
play(t(), move()) :: {:ok, t()} | error()

Play a move. a move looks like “e2e4”.

Link to this function san_to_move(position, san)
san_to_move(t(), String.t()) :: {:ok, String.t()} | error()

Transforms a short algebraic notation to a move. eg. “Nf3” -> “g1f3”.