forked from BattlesnakeOfficial/rules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
constrictor.go
48 lines (41 loc) · 1.18 KB
/
constrictor.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
package rules
var constrictorRulesetStages = []string{
StageGameOverStandard,
StageMovementStandard,
StageStarvationStandard,
StageHazardDamageStandard,
StageFeedSnakesStandard,
StageEliminationStandard,
StageSpawnFoodNoFood,
StageModifySnakesAlwaysGrow,
}
var wrappedConstrictorRulesetStages = []string{
StageGameOverStandard,
StageMovementWrapBoundaries,
StageStarvationStandard,
StageHazardDamageStandard,
StageFeedSnakesStandard,
StageEliminationStandard,
StageSpawnFoodNoFood,
StageModifySnakesAlwaysGrow,
}
func RemoveFoodConstrictor(b *BoardState, settings Settings, moves []SnakeMove) (bool, error) {
// Remove all food from the board
b.Food = []Point{}
return false, nil
}
func GrowSnakesConstrictor(b *BoardState, settings Settings, moves []SnakeMove) (bool, error) {
// Set all snakes to max health and ensure they grow next turn
for i := 0; i < len(b.Snakes); i++ {
if len(b.Snakes[i].Body) <= 0 {
return false, ErrorZeroLengthSnake
}
b.Snakes[i].Health = SnakeMaxHealth
tail := b.Snakes[i].Body[len(b.Snakes[i].Body)-1]
subTail := b.Snakes[i].Body[len(b.Snakes[i].Body)-2]
if tail != subTail {
growSnake(&b.Snakes[i])
}
}
return false, nil
}