From 11e573510954788b5cc36200be20269079612aff Mon Sep 17 00:00:00 2001 From: Brad Van Vugt <1531419+bvanvugt@users.noreply.github.com> Date: Wed, 1 Jan 2020 17:22:00 -0800 Subject: [PATCH] Update models.go --- models.go | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/models.go b/models.go index c3d395b..7a2f38e 100644 --- a/models.go +++ b/models.go @@ -1,23 +1,11 @@ package rulesets -// NOTE: IMMUTABLE THINGS HERE // - -const MOVE_UP = "up" -const MOVE_DOWN = "down" -const MOVE_RIGHT = "right" -const MOVE_LEFT = "left" - -type Game struct { - Height int32 - Width int32 -} - -type SnakeMove struct { - Snake *Snake - Move string -} - -// NOTE: MUTABLE THINGS HERE // +const ( + MOVE_UP = "up" + MOVE_DOWN = "down" + MOVE_RIGHT = "right" + MOVE_LEFT = "left" +) type Point struct { X int32 @@ -31,13 +19,19 @@ type Snake struct { EliminatedCause string } -type GameState struct { +type BoardState struct { + Height int32 + Width int32 Food []*Point Snakes []*Snake } -// RULESET API // +type SnakeMove struct { + Snake *Snake + Move string +} 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) }