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.
This commit is contained in:
Dan Buch
2012-12-16 17:59:54 -05:00
parent 3bfa23fff2
commit 3e013ce1a5
6 changed files with 114 additions and 46 deletions

View File

@@ -14,6 +14,7 @@ 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")
)
@@ -21,9 +22,21 @@ var (
func main() {
flag.Parse()
retCode, err := RunConsoleGame(*height, *width, *sleepMs, *mutate)
if err != nil {
fmt.Fprintf(os.Stderr, "ERROR: %v\n", err)
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)