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