Update models.go
This commit is contained in:
parent
798be609ba
commit
11e5735109
1 changed files with 15 additions and 21 deletions
36
models.go
36
models.go
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue