You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
929 B

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 a web-based game.")
addr = flag.String("addr", ":9775",
"Address for server of web-based game (ignored if running a console 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(*addr, *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)
}