Byte-snake-engine/ruleset.go

40 lines
679 B
Go
Raw Normal View History

2020-01-05 17:08:05 -08:00
package rules
2019-12-31 20:43:05 -08:00
2020-01-01 17:22:00 -08:00
const (
MoveUp = "up"
MoveDown = "down"
MoveRight = "right"
MoveLeft = "left"
2020-01-01 17:22:00 -08:00
)
2019-12-31 20:43:05 -08:00
type Point struct {
X int32
Y int32
}
type Snake struct {
ID string
Body []Point
2019-12-31 20:43:05 -08:00
Health int32
EliminatedCause string
EliminatedBy string
2019-12-31 20:43:05 -08:00
}
2020-01-01 17:22:00 -08:00
type BoardState struct {
Height int32
Width int32
Food []Point
Snakes []Snake
2019-12-31 20:43:05 -08:00
}
2020-01-01 17:22:00 -08:00
type SnakeMove struct {
ID string
Move string
2020-01-01 17:22:00 -08:00
}
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)
CreateNextBoardState(prevState *BoardState, moves []SnakeMove) (*BoardState, error)
2020-05-17 14:38:39 -07:00
IsGameOver(state *BoardState) (bool, error)
2019-12-31 20:43:05 -08:00
}