Merge branch 'master' of github.com:BattlesnakeOfficial/rules
This commit is contained in:
commit
60c0b149ba
3 changed files with 84 additions and 3 deletions
12
standard.go
12
standard.go
|
|
@ -1,4 +1,4 @@
|
|||
package rulesets
|
||||
package rules
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
|
@ -183,6 +183,13 @@ func (r *StandardRuleset) ResolveMoves(prevState *BoardState, moves []SnakeMove)
|
|||
}
|
||||
|
||||
func (r *StandardRuleset) moveSnakes(b *BoardState, moves []SnakeMove) error {
|
||||
if len(moves) < len(b.Snakes) {
|
||||
return errors.New("not enough snake moves")
|
||||
}
|
||||
if len(moves) > len(b.Snakes) {
|
||||
return errors.New("too many snake moves")
|
||||
}
|
||||
|
||||
for _, move := range moves {
|
||||
var snake *Snake
|
||||
for i := 0; i < len(b.Snakes); i++ {
|
||||
|
|
@ -190,6 +197,9 @@ func (r *StandardRuleset) moveSnakes(b *BoardState, moves []SnakeMove) error {
|
|||
snake = &b.Snakes[i]
|
||||
}
|
||||
}
|
||||
if snake == nil {
|
||||
return errors.New("snake not found for move")
|
||||
}
|
||||
|
||||
// Do not move eliminated snakes
|
||||
if snake.EliminatedCause != NotEliminated {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue