box-o-sand/conway/conways-game-of-life/main.go
Dan Buch 3e013ce1a5 Too much crap for one commit
Breaking out console runner into its own file, adding an empty web
runner, and starting to test that games and game states are able to
represent themselves as images.
2012-12-16 17:59:54 -05:00

44 lines
816 B
Go

package main
import (
"flag"
"fmt"
"os"
)
import (
. "github.com/meatballhat/box-o-sand/conway"
)
var (
height = flag.Int("height", 40, "Game height")
width = flag.Int("width", 80, "Game width")
mutate = flag.Bool("mutate", false, "Mutate every other generation")
web = flag.Bool("web", false, "Run server for web-based game")
sleepMs = flag.Int("sleep.ms", 200,
"Millisecond sleep interval per generation")
)
func main() {
flag.Parse()
var (
retCode int
err error
)
if *web {
retCode, err = RunWebGame(*height, *width, *sleepMs, *mutate)
if err != nil {
fmt.Fprintf(os.Stderr, "ERROR: %v\n", err)
}
} else {
retCode, err = RunConsoleGame(*height, *width, *sleepMs, *mutate)
if err != nil {
fmt.Fprintf(os.Stderr, "ERROR: %v\n", err)
}
}
os.Exit(retCode)
}