DEV 1303: Add empty and royale maps and update game map interface (#72)

* move random generator into Settings

* add empty and royale maps

* place snakes on either cardinal or corner positions first
This commit is contained in:
Rob O'Dwyer 2022-05-17 15:45:56 -07:00 committed by GitHub
parent 6fa2da2f01
commit e94d758a9b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 479 additions and 52 deletions

View file

@ -24,9 +24,6 @@ type Metadata struct {
// Editor is used by GameMap implementations to modify the board state.
type Editor interface {
// Returns a random number generator. This MUST be used for any non-deterministic behavior in a GameMap.
Random() rules.Rand
// Clears all food from the board.
ClearFood()
@ -52,18 +49,14 @@ type Editor interface {
// An Editor backed by a BoardState.
type BoardStateEditor struct {
*rules.BoardState
rand rules.Rand
}
func NewBoardStateEditor(boardState *rules.BoardState, rand rules.Rand) *BoardStateEditor {
func NewBoardStateEditor(boardState *rules.BoardState) *BoardStateEditor {
return &BoardStateEditor{
BoardState: boardState,
rand: rand,
}
}
func (editor *BoardStateEditor) Random() rules.Rand { return editor.rand }
func (editor *BoardStateEditor) ClearFood() {
editor.Food = []rules.Point{}
}