2019-12-31 20:43:05 -08:00
|
|
|
package rulesets
|
|
|
|
|
|
2020-01-01 17:22:00 -08:00
|
|
|
const (
|
|
|
|
|
MOVE_UP = "up"
|
|
|
|
|
MOVE_DOWN = "down"
|
|
|
|
|
MOVE_RIGHT = "right"
|
|
|
|
|
MOVE_LEFT = "left"
|
|
|
|
|
)
|
2019-12-31 20:43:05 -08:00
|
|
|
|
|
|
|
|
type Point struct {
|
|
|
|
|
X int32
|
|
|
|
|
Y int32
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Snake struct {
|
|
|
|
|
ID string
|
|
|
|
|
Body []*Point
|
|
|
|
|
Health int32
|
|
|
|
|
EliminatedCause string
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-01 17:22:00 -08:00
|
|
|
type BoardState struct {
|
|
|
|
|
Height int32
|
|
|
|
|
Width int32
|
2019-12-31 20:43:05 -08:00
|
|
|
Food []*Point
|
|
|
|
|
Snakes []*Snake
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-01 17:22:00 -08:00
|
|
|
type SnakeMove struct {
|
|
|
|
|
Snake *Snake
|
|
|
|
|
Move string
|
|
|
|
|
}
|
2019-12-31 20:43:05 -08:00
|
|
|
|
|
|
|
|
type Ruleset interface {
|
2020-01-01 17:22:00 -08:00
|
|
|
CreateInitialBoardState(width int32, height int32, snakeIDs []string) (*BoardState, error)
|
|
|
|
|
ResolveMoves(prevState *BoardState, moves []*SnakeMove) (*BoardState, error)
|
2019-12-31 20:43:05 -08:00
|
|
|
}
|