From ecffff2a60093c8a45702806960e3d4fcb4e2b76 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Sat, 8 Dec 2012 21:47:21 -0500 Subject: [PATCH] Starting work on a Go implementation of Conway's Game of Life since I had a decent amount of practice at http://globalday.coderetreat.org/ --- conway/go/Makefile | 23 +++++++++++++++++++++++ conway/go/conway_test.go | 16 ++++++++++++++++ conway/go/conways-game-of-life/main.go | 5 +++++ conway/go/game_of_life.go | 13 +++++++++++++ 4 files changed, 57 insertions(+) create mode 100644 conway/go/Makefile create mode 100644 conway/go/conway_test.go create mode 100644 conway/go/conways-game-of-life/main.go create mode 100644 conway/go/game_of_life.go diff --git a/conway/go/Makefile b/conway/go/Makefile new file mode 100644 index 0000000..e283d23 --- /dev/null +++ b/conway/go/Makefile @@ -0,0 +1,23 @@ +LIBS := \ + github.com/meatballhat/box-o-sand/conway/go +TARGETS := \ + $(LIBS) \ + github.com/meatballhat/box-o-sand/conway/go/conways-game-of-life + + +all: deps build + + +build: test + go install -x $(TARGETS) + + +test: + go test -x -v -test.parallel=4 $(LIBS) + + +deps: + go get -x $(TARGETS) + + +.PHONY: all build test deps diff --git a/conway/go/conway_test.go b/conway/go/conway_test.go new file mode 100644 index 0000000..c8b0945 --- /dev/null +++ b/conway/go/conway_test.go @@ -0,0 +1,16 @@ +package conway_test + +import ( + "testing" +) + +import ( + . "github.com/meatballhat/box-o-sand/conway/go" +) + +func TestNewGameOfLifeIsNonEmpty(t *testing.T) { + game := NewGameOfLife() + if game.Height < 1 || game.Width < 1 { + t.Fail() + } +} diff --git a/conway/go/conways-game-of-life/main.go b/conway/go/conways-game-of-life/main.go new file mode 100644 index 0000000..e0b87a2 --- /dev/null +++ b/conway/go/conways-game-of-life/main.go @@ -0,0 +1,5 @@ +package main + +func main() { + return +} diff --git a/conway/go/game_of_life.go b/conway/go/game_of_life.go new file mode 100644 index 0000000..f945798 --- /dev/null +++ b/conway/go/game_of_life.go @@ -0,0 +1,13 @@ +package conway + +type GameOfLife struct { + Height uint8 + Width uint8 +} + +func NewGameOfLife() *GameOfLife { + return &GameOfLife{ + Height: 16, + Width: 16, + } +}