2012-12-09 02:47:21 +00:00
|
|
|
package main
|
|
|
|
|
2012-12-10 04:20:43 +00:00
|
|
|
import (
|
2012-12-10 04:38:38 +00:00
|
|
|
"flag"
|
2012-12-10 04:20:43 +00:00
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
|
|
|
import (
|
2012-12-11 23:28:10 +00:00
|
|
|
. "github.com/meatballhat/box-o-sand/conway"
|
2012-12-10 04:20:43 +00:00
|
|
|
)
|
|
|
|
|
2012-12-10 04:38:38 +00:00
|
|
|
var (
|
|
|
|
height = flag.Int("height", 40, "Game height")
|
|
|
|
width = flag.Int("width", 80, "Game width")
|
2012-12-10 05:19:31 +00:00
|
|
|
mutate = flag.Bool("mutate", false, "Mutate every other generation")
|
2012-12-16 22:59:54 +00:00
|
|
|
web = flag.Bool("web", false, "Run server for web-based game")
|
2012-12-10 14:14:29 +00:00
|
|
|
sleepMs = flag.Int("sleep.ms", 200,
|
2012-12-10 04:38:38 +00:00
|
|
|
"Millisecond sleep interval per generation")
|
|
|
|
)
|
|
|
|
|
2012-12-09 02:47:21 +00:00
|
|
|
func main() {
|
2012-12-10 04:38:38 +00:00
|
|
|
flag.Parse()
|
|
|
|
|
2012-12-16 22:59:54 +00:00
|
|
|
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)
|
|
|
|
}
|
2012-12-10 04:20:43 +00:00
|
|
|
}
|
|
|
|
|
2012-12-13 02:33:53 +00:00
|
|
|
os.Exit(retCode)
|
2012-12-09 02:47:21 +00:00
|
|
|
}
|