generated from BattlesnakeOfficial/starter-snake-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.go
114 lines (99 loc) · 2.36 KB
/
models.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package main
// API Objects
// https://docs.battlesnake.com/api
type Coord struct {
X int `json:"x"`
Y int `json:"y"`
}
type Battlesnake struct {
ID string `json:"id"`
Name string `json:"name"`
Health int `json:"health"`
Body []Coord `json:"body"`
Head Coord `json:"head"`
Length int `json:"length"`
Latency string `json:"latency"`
Shout string `json:"shout"`
Customizations Customizations `json:"customizations"`
}
type Customizations struct {
Color string `json:"color"`
Head string `json:"head"`
Tail string `json:"tail"`
}
type Board struct {
Height int `json:"height"`
Width int `json:"width"`
Food []Coord `json:"food"`
Hazards []Coord `json:"hazards"`
Snakes []Battlesnake `json:"snakes"`
}
type GameState struct {
Game Game `json:"game"`
Turn int `json:"turn"`
Board Board `json:"board"`
You Battlesnake `json:"you"`
}
type Game struct {
ID string `json:"id"`
Ruleset Ruleset `json:"ruleset"`
Map string `json:"map"`
Source string `json:"source"`
Timeout int `json:"timeout"`
}
type Ruleset struct {
Name string `json:"name"`
Version string `json:"version"`
Settings RulesetSettings `json:"settings"`
}
type RulesetSettings struct {
FoodSpawnChance int `json:"foodSpawnChance"`
MinimumFood int `json:"minimumFood"`
HazardDamagePerTurn int `json:"hazardDamagePerTurn"`
}
// Response Objects
// https://docs.battlesnake.com/api
type BattlesnakeInfoResponse struct {
APIVersion string `json:"apiversion"`
Author string `json:"author"`
Color string `json:"color"`
Head string `json:"head"`
Tail string `json:"tail"`
}
type BattlesnakeMoveResponse struct {
Move string `json:"move"`
Shout string `json:"shout"`
}
type Move struct {
Name string
Direction Coord
}
var snakeHeads = []string{
"regular",
"beluga",
"bendr",
"dead",
"evil",
"fang",
"pixel",
"safe",
"sand-worm",
"shades",
"silly",
"smile",
"tongue",
}
var snakeTails = []string{
"regular",
"block-bum",
"bolt",
"curled",
"fat-rattle",
"freckled",
"hook",
"pixel",
"round-bum",
"sharp",
"skinny",
"small-rattle",
}