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/
This commit is contained in:
parent
6bd27f93b8
commit
ecffff2a60
23
conway/go/Makefile
Normal file
23
conway/go/Makefile
Normal file
@ -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
|
16
conway/go/conway_test.go
Normal file
16
conway/go/conway_test.go
Normal file
@ -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()
|
||||||
|
}
|
||||||
|
}
|
5
conway/go/conways-game-of-life/main.go
Normal file
5
conway/go/conways-game-of-life/main.go
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
return
|
||||||
|
}
|
13
conway/go/game_of_life.go
Normal file
13
conway/go/game_of_life.go
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package conway
|
||||||
|
|
||||||
|
type GameOfLife struct {
|
||||||
|
Height uint8
|
||||||
|
Width uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewGameOfLife() *GameOfLife {
|
||||||
|
return &GameOfLife{
|
||||||
|
Height: 16,
|
||||||
|
Width: 16,
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user