Go v0.4.0 Go.Game View Source
Documentation for Go.Game
This is the main entity since version 0.2.0
It manages the count (komi, captures) and history of turns. It manages superko rule
It delegates rest of play to a current_board
June 2017-2018, hf
Examples
iex> alias Go.Game
iex> game = Game.new
iex> {:ok, game} = game |> Game.add_move({{3, 3}, :black})
iex> {:ok, game} = game |> Game.add_move({{16, 3}, :white})
iex> {:ok, game} = game |> Game.add_move({{3, 16}, :black})
iex> {:ok, game} = game |> Game.add_move({{16, 16}, :white})
iex> current_board = game.current_board
iex> current_board.coordinates[{3, 3}]
:black
iex> current_board.coordinates[{16, 16}]
:white
Link to this section Summary
Functions
Add move to a game
Imports a game from sgf, does not persists nodes, just moves from main branch! and thus… does not save root node info
Returns a new Game structure from an optional map or struct
Pass move
Place one stone on the game
Remove the stone at the given location
Reset the game, but keep size and komi
Resign the game, status will change to is_over
Returns the tally of the game
Generate an ascii from current board game
Returns list from current board game
Exports a game to sgf, just returns moves played, no properties, comments!
Like pass move, but does not change history state. Useful when parsing faulty variations in KJD
Link to this section Types
t() :: %Go.Game{ black_captures: integer(), consecutive_passes: integer(), current_board: Go.Board.t(), is_over: boolean(), komi: float(), placements: list(), size: integer(), turns: [Go.Turn.t()], white_captures: integer(), winner: Go.Board.color() | :none }
Link to this section Functions
add_move(t(), {Go.Board.coordinate(), Go.Board.color()}) :: {:ok, t()} | {:error, String.t()}
Add move to a game.
Imports a game from sgf, does not persists nodes, just moves from main branch! and thus… does not save root node info
Returns a new Game structure from an optional map or struct.
pass(t(), Go.Board.color()) :: {:ok, t()} | {:error, String.t()}
Pass move.
Place one stone on the game.
place_stone(t(), Go.Board.coordinate(), Go.Board.color(), boolean()) :: {:ok, t()} | {:error, String.t()}
place_stones(t(), Go.Board.list_of_coordinates(), Go.Board.color()) :: {:ok, t()} | {:error, String.t()}
remove_stone(t(), Go.Board.coordinate()) :: {:ok, t()}
Remove the stone at the given location.
remove_stones(t(), Go.Board.list_of_coordinates()) :: {:ok, t()}
Reset the game, but keep size and komi
Resign the game, status will change to is_over
Returns the tally of the game
Generate an ascii from current board game.
Returns list from current board game.
Exports a game to sgf, just returns moves played, no properties, comments!
Like pass move, but does not change history state. Useful when parsing faulty variations in KJD.