Echecs (Echecs v0.1.5)

Copy Markdown View Source

Echecs is a pure Elixir chess library for move generation, validation, and game state management.

This module is the main entry point: new_game/0 and new_game/1 build a %Echecs.Game{} from the start position or a FEN string, legal_moves/1 lists legal moves, make_move/4 applies one if legal ({:ok, game} / {:error, :illegal_move}), and status/1 reports :active, :checkmate, :stalemate or :draw. Internals live in Echecs.Game, Echecs.MoveGen and Echecs.Board.

Summary

Functions

Returns a list of all legal moves for the current game state.

Starts a new chess game with the standard starting position.

Starts a new chess game from a given FEN string.

Returns the current status of the game (:active, :checkmate, :stalemate, :draw).

Functions

make_move(game, from_sq, to_sq, promotion \\ nil)

Makes a move if it is legal.

Returns {:ok, new_game} or {:error, reason}.

new_game()

Starts a new chess game with the standard starting position.

new_game(fen)

Starts a new chess game from a given FEN string.

status(game)

Returns the current status of the game (:active, :checkmate, :stalemate, :draw).