-
Notifications
You must be signed in to change notification settings - Fork 15
/
main.go
57 lines (50 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
package main
import (
"flag"
"fmt"
"os"
"strconv"
"github.com/geetarista/vindinium-starter-go/vindinium"
)
var (
client vindinium.Client
count string
games int
)
func init() {
flag.StringVar(&client.Server, "s", "http://vindinium.org", "server")
flag.StringVar(&client.Key, "k", "", "api key")
flag.StringVar(&client.Mode, "m", "arena", "mode (arena or training)")
flag.StringVar(&client.BotName, "b", "fighter", "name of bot to use")
flag.StringVar(&count, "c", "1", "number of games or turns to play")
flag.BoolVar(&client.RandomMap, "r", true, "use random map (useful for training against same map)")
flag.BoolVar(&client.Debug, "d", false, "debug output")
flag.Usage = func() {
fmt.Printf("Usage %s [FLAGS]\n", os.Args[0])
flag.PrintDefaults()
}
flag.Parse()
}
func main() {
if client.Key == "" {
fmt.Println("API key required. Pass using the -k flag. Use -h to view help.")
os.Exit(1)
}
if client.Mode == "training" {
games = 1
client.Turns = count
} else {
games, _ = strconv.Atoi(count)
client.Turns = "300"
}
client.Setup()
for i := 0; i < games; i++ {
if err := client.Start(); err != nil {
panic(err.Error())
}
if err := client.Play(); err != nil {
panic(err.Error())
}
}
fmt.Printf("Finished %d games.\n", games)
}