Byte-snake-engine/ruleset.go
Brad Van Vugt 8153585f57
Add "EliminatedBy" to snake eliminations. (#11)
* add eliminated by

* add test

* make sure largest snake is listed as eliminator on head to head collisions

* remove unused type def

* Reduce memory usage during elimination checks.

Co-authored-by: Daniel Steuernol <dlsteuer@gmail.com>
2020-02-19 11:44:48 -08:00

38 lines
626 B
Go

package rules
const (
MoveUp = "up"
MoveDown = "down"
MoveRight = "right"
MoveLeft = "left"
)
type Point struct {
X int32
Y int32
}
type Snake struct {
ID string
Body []Point
Health int32
EliminatedCause string
EliminatedBy string
}
type BoardState struct {
Height int32
Width int32
Food []Point
Snakes []Snake
}
type SnakeMove struct {
ID string
Move string
}
type Ruleset interface {
CreateInitialBoardState(width int32, height int32, snakeIDs []string) (*BoardState, error)
ResolveMoves(prevState *BoardState, moves []SnakeMove) (*BoardState, error)
}