DEV-280: Extract board generation out of rules.Ruleset (#51)

* extract board generation out of rules.Ruleset

* update comment and remove redundant interface check

* clone boardState in constrictor to respect the ModifyBoardState interface
This commit is contained in:
Rob O'Dwyer 2021-08-23 17:13:58 -07:00 committed by GitHub
parent e416384007
commit 015b681f14
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 1006 additions and 917 deletions

View file

@ -46,14 +46,6 @@ type Snake struct {
EliminatedBy string
}
type BoardState struct {
Height int32
Width int32
Food []Point
Snakes []Snake
Hazards []Point
}
type SnakeMove struct {
ID string
Move string
@ -61,7 +53,7 @@ type SnakeMove struct {
type Ruleset interface {
Name() string
CreateInitialBoardState(width int32, height int32, snakeIDs []string) (*BoardState, error)
ModifyInitialBoardState(initialState *BoardState) (*BoardState, error)
CreateNextBoardState(prevState *BoardState, moves []SnakeMove) (*BoardState, error)
IsGameOver(state *BoardState) (bool, error)
}