generated from UoB-CSA/gol-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
68 lines (56 loc) · 1.26 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
"flag"
"fmt"
"runtime"
"uk.ac.bris.cs/gameoflife/gol"
"uk.ac.bris.cs/gameoflife/sdl"
)
// main is the function called when starting Game of Life with 'go run .'
func main() {
runtime.LockOSThread()
var params gol.Params
flag.IntVar(
¶ms.Threads,
"t",
8,
"Specify the number of worker threads to use. Defaults to 8.")
flag.IntVar(
¶ms.ImageWidth,
"w",
512,
"Specify the width of the image. Defaults to 512.")
flag.IntVar(
¶ms.ImageHeight,
"h",
512,
"Specify the height of the image. Defaults to 512.")
flag.IntVar(
¶ms.Turns,
"turns",
10000000000,
"Specify the number of turns to process. Defaults to 10000000000.")
noVis := flag.Bool(
"noVis",
false,
"Disables the SDL window, so there is no visualisation during the tests.")
flag.Parse()
fmt.Println("Threads:", params.Threads)
fmt.Println("Width:", params.ImageWidth)
fmt.Println("Height:", params.ImageHeight)
keyPresses := make(chan rune, 10)
events := make(chan gol.Event, 1000)
go gol.Run(params, events, keyPresses)
if !(*noVis) {
sdl.Run(params, events, keyPresses)
} else {
complete := false
for !complete {
event := <-events
switch event.(type) {
case gol.FinalTurnComplete:
complete = true
}
}
}
}