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:
parent
e416384007
commit
015b681f14
8 changed files with 1006 additions and 917 deletions
10
ruleset.go
10
ruleset.go
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue