Implemented TestCreateNextBoardState (#15)

This commit is contained in:
sjbcastro 2020-05-28 19:26:44 +01:00 committed by GitHub
parent 2d62a58c9b
commit 70a8107a6f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 107 additions and 1 deletions

View file

@ -185,6 +185,11 @@ func (r *StandardRuleset) CreateNextBoardState(prevState *BoardState, moves []Sn
}
func (r *StandardRuleset) moveSnakes(b *BoardState, moves []SnakeMove) error {
for i := 0; i < len(b.Snakes); i++ {
if len(b.Snakes[i].Body) == 0 {
return errors.New("found snake with zero size body")
}
}
if len(moves) < len(b.Snakes) {
return errors.New("not enough snake moves")
}