Cleaning better and using chars with more contrast.

This commit is contained in:
Dan Buch 2012-12-11 18:43:15 -05:00
parent df55a809f1
commit 0ac0b4cab9
2 changed files with 10 additions and 7 deletions

View File

@ -4,20 +4,18 @@ TARGETS := \
$(LIBS) \ $(LIBS) \
github.com/meatballhat/box-o-sand/conway/conways-game-of-life github.com/meatballhat/box-o-sand/conway/conways-game-of-life
all: deps build all: deps build
build: test build: test
go install -x $(TARGETS) go install -x $(TARGETS)
clean:
go clean -x -i $(TARGETS)
test: test:
go test -x -v -test.parallel=4 $(LIBS) go test -x -v -test.parallel=4 $(LIBS)
deps: deps:
go get -x $(TARGETS) go get -x $(TARGETS)
.PHONY: all build clean deps test
.PHONY: all build test deps

View File

@ -10,6 +10,11 @@ import (
"time" "time"
) )
const (
DEAD_CELL = "■"
LIVE_CELL = " "
)
func init() { func init() {
rand.Seed(time.Now().UTC().UnixNano()) rand.Seed(time.Now().UTC().UnixNano())
} }
@ -284,7 +289,7 @@ func (state *GameState) String() string {
for y := 0; y < height; y++ { for y := 0; y < height; y++ {
var cells []string var cells []string
for x := 0; x < width; x++ { for x := 0; x < width; x++ {
stringVal := "■" stringVal := DEAD_CELL
value, err := state.Get(x, y) value, err := state.Get(x, y)
if err != nil { if err != nil {
@ -292,7 +297,7 @@ func (state *GameState) String() string {
} }
if value == 1 { if value == 1 {
stringVal = "□" stringVal = LIVE_CELL
} }
cells = append(cells, stringVal) cells = append(cells, stringVal)
} }