Skip to content

elixir struct for the game of go (not the go language)

Notifications You must be signed in to change notification settings

kokolegorille/go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go

Description

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.

Installation

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

Available in Hex.

Usage

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+++++
+++++++++
+++++++++
+++++++++
+++++++++
+++++++++

TextClient

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)

About

elixir struct for the game of go (not the go language)

Resources

Stars

Watchers

Forks

Packages

No packages published