chess_logic v0.3.0 ChessLogic
Documentation for ChessLogic API.
It mostly delegates to Game
- To play a game...
iex> g = ChessLogic.new_game iex> {:ok, g} = ChessLogic.play(g, "e4") iex> {:ok, g} = ChessLogic.play(g, "e5")
To print a game iex> ChessLogic.print_game g ♜ ♞ ♝ ♛ ♚ ♝ ♞ ♜ ♟ ♟ ♟ ♟ ♟ ♟ ♟
♟ ♙
♙ ♙ ♙ ♙ ♙ ♙ ♙ ♖ ♘ ♗ ♕ ♔ ♗ ♘ ♖
- Import/Export PGN
To test Import from PGN, You can use test/fixtures files, for example, games from Grenke 2018. (It takes some time to load games, as it not optimized)
iex> games = ChessLogic.from_pgn_file "./test/fixtures/GRENKEChessClassic2018.pgn"
To export... iex> games |> Enum.map(fn game -> ChessLogic.to_pgn(game) end)
FILES NEEDS TO BE UTF8! If it is not, You can add iconv for conversion.
Link to this section Summary
Link to this section Functions
Link to this function
draw(game)
Link to this function
from_pgn(pgn)
Link to this function
from_pgn_file(file)
Link to this function
new_game()
Link to this function
new_game(fen)
Link to this function
play(game, move)
Link to this function
print_game(game)
Link to this function
resign(game)
Link to this function
set_result(game, result)
Link to this function