add turn to BoardState and remove it from RoyaleRuleset (#52)

This commit is contained in:
Rob O'Dwyer 2021-08-27 13:28:12 -07:00 committed by GitHub
parent 17556e15c1
commit e9f408cdbb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 27 deletions

View file

@ -3,6 +3,7 @@ package rules
import "math/rand"
type BoardState struct {
Turn int32
Height int32
Width int32
Food []Point
@ -13,6 +14,7 @@ type BoardState struct {
// NewBoardState returns an empty but fully initialized BoardState
func NewBoardState(width, height int32) *BoardState {
return &BoardState{
Turn: 0,
Height: height,
Width: width,
Food: []Point{},
@ -24,6 +26,7 @@ func NewBoardState(width, height int32) *BoardState {
// Clone returns a deep copy of prevState that can be safely modified inside Ruleset.CreateNextBoardState
func (prevState *BoardState) Clone() *BoardState {
nextState := &BoardState{
Turn: prevState.Turn,
Height: prevState.Height,
Width: prevState.Width,
Food: append([]Point{}, prevState.Food...),