-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
46 lines (40 loc) · 1.14 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"flag"
"fmt"
"log"
"os"
"path/filepath"
"syscall"
)
var public, HTMLfile *string
var width, height, port *uint
var headless *bool
var ipp *float64
func init() {
flag.Usage = usage
d, err := filepath.Abs(filepath.Dir(os.Args[0]))
if err != nil {
log.Fatal(err)
}
public = flag.String("public", d+"/public", "path to public directory")
HTMLfile = flag.String("HTMLfile", "automatic.html", "HTML file name (with extention)")
port = flag.Uint("port", 7272, "the port where the simulation server starts")
headless = flag.Bool("headless", false, "whether to run an headless simulation")
width = flag.Uint("width", 25, "the width of the simulation world")
height = flag.Uint("height", 25, "the height of the simulation world")
ipp = flag.Float64("ipp", 0.3, "initial population percentage")
flag.Parse()
}
func usage() {
fmt.Println("sim")
flag.PrintDefaults()
os.Exit(2)
}
func main() {
sim := NewSimulation(int(*width), int(*height))
sim.Init(*ipp)
server := NewBrowserSimulationServer(sim, "0.0.0.0", *port, *public, *HTMLfile, *headless)
server.AddTerminationSignals(os.Interrupt, syscall.SIGTERM)
server.Serve()
}