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

Link to this type t() View Source
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

Link to this function add_move(game, move) View Source
add_move(t(), {Go.Board.coordinate(), Go.Board.color()}) ::
  {:ok, t()} | {:error, String.t()}

Add move to a game.

Link to this function apply_action(state, action) View Source
Link to this function from_sgf(sgf) View Source
from_sgf(String.t()) :: {:ok, t()} | {:error, term()}

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.

Link to this function new(initial_state) View Source
new(nil | map()) :: t()
Link to this function pass(game, color) View Source
pass(t(), Go.Board.color()) :: {:ok, t()} | {:error, String.t()}

Pass move.

Link to this function place_stone(game, coordinate, color) View Source

Place one stone on the game.

Link to this function place_stone(game, coordinate, color, force \\ false) View Source
place_stone(t(), Go.Board.coordinate(), Go.Board.color(), boolean()) ::
  {:ok, t()} | {:error, String.t()}
Link to this function place_stones(game, list, color) View Source
place_stones(t(), Go.Board.list_of_coordinates(), Go.Board.color()) ::
  {:ok, t()} | {:error, String.t()}
Link to this function remove_stone(game, coordinate) View Source
remove_stone(t(), Go.Board.coordinate()) :: {:ok, t()}

Remove the stone at the given location.

Link to this function remove_stones(game, arg2) View Source
remove_stones(t(), Go.Board.list_of_coordinates()) :: {:ok, t()}
Link to this function reset(game) View Source
reset(t()) :: {:ok, t()}

Reset the game, but keep size and komi

Link to this function resign(game, color) View Source
resign(t(), Go.Board.color()) :: {:ok, t()}

Resign the game, status will change to is_over

Link to this function tally(game) View Source
tally(t()) :: map()

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!

Link to this function toggle_turn(game) View Source
toggle_turn(t()) :: {:ok, t()}

Like pass move, but does not change history state. Useful when parsing faulty variations in KJD.