Update models.go

This commit is contained in:
Brad Van Vugt 2020-01-01 17:22:00 -08:00 committed by GitHub
parent 798be609ba
commit 11e5735109
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,23 +1,11 @@
package rulesets package rulesets
// NOTE: IMMUTABLE THINGS HERE // const (
MOVE_UP = "up"
const MOVE_UP = "up" MOVE_DOWN = "down"
const MOVE_DOWN = "down" MOVE_RIGHT = "right"
const MOVE_RIGHT = "right" MOVE_LEFT = "left"
const MOVE_LEFT = "left" )
type Game struct {
Height int32
Width int32
}
type SnakeMove struct {
Snake *Snake
Move string
}
// NOTE: MUTABLE THINGS HERE //
type Point struct { type Point struct {
X int32 X int32
@ -31,13 +19,19 @@ type Snake struct {
EliminatedCause string EliminatedCause string
} }
type GameState struct { type BoardState struct {
Height int32
Width int32
Food []*Point Food []*Point
Snakes []*Snake Snakes []*Snake
} }
// RULESET API // type SnakeMove struct {
Snake *Snake
Move string
}
type Ruleset interface { type Ruleset interface {
ResolveMoves(*Game, *GameState, []*SnakeMove) (*GameState, error) CreateInitialBoardState(width int32, height int32, snakeIDs []string) (*BoardState, error)
ResolveMoves(prevState *BoardState, moves []*SnakeMove) (*BoardState, error)
} }