This package contains logic to play the game of go. Nothing related to the go language... It is godash ported to elixir, but it checks also ko rule, and holds information about captures count.
The package can be installed by adding elixir_go
to your list of dependencies in mix.exs
:
def deps do
[{:elixir_go, "~> 0.4.0"}]
end
See tests for sample usage.
iex> alias Go.{Game, Board}
iex> game = Game.new(%{size: 9})
iex> {:ok, game} = Game.add_move(game, {{2, 2}, :black})
iex> {:ok, game} = Game.add_move(game, {{3, 3}, :white})
iex> game.current_board |> Board.to_ascii_board |> IO.puts
+++++++++
+++++++++
++O++++++
+++X+++++
+++++++++
+++++++++
+++++++++
+++++++++
+++++++++
Add TextClient CLI for text based game
iex> Go.TextClient.start
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
game_state: running
move_number: 0
winner: none
black's move: cc
+++++++++++++++++++
+++++++++++++++++++
++O++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
+++++++++++++++++++
game_state: running
move_number: 1
winner: none
white's move: resign
game over, the winner is black
** (exit) normal
(elixir_go) lib/go/text_client/player.ex:8: Go.TextClient.Player.play/1
It is now possible to import/export sgf files.
iex> filename = "test/fixtures/example.sgf"
iex> {:ok, sgf} = File.read filename
iex> {:ok, game} = Go.Game.from_sgf(sgf)