Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV 1761: Add new BoardState and Point fields #117

Merged
merged 2 commits into from
Oct 28, 2022

Conversation

robbles
Copy link
Contributor

@robbles robbles commented Oct 27, 2022

The important changes are all here:

rules/board.go

Lines 8 to 28 in a716356

type BoardState struct {
Turn int
Height int
Width int
Food []Point
Snakes []Snake
Hazards []Point
// Generic game-level state for maps and rules stages to persist data between turns.
GameState map[string]string
// Numeric state keyed to specific points, also persisted between turns.
PointState map[Point]int
}
type Point struct {
X int `json:"X"`
Y int `json:"Y"`
TTL int `json:"TTL,omitempty"`
Value int `json:"Value,omitempty"`
}

Nothing is being done with the new fields yet, but they are persisted through cloning of the BoardState.

@robbles robbles changed the base branch from main to rules-2.0 October 27, 2022 21:32
@robbles robbles marked this pull request as ready for review October 27, 2022 21:33
@robbles robbles merged commit 3a4f618 into rules-2.0 Oct 28, 2022
@robbles robbles deleted the DEV-1761-add-boardstate-fields branch October 28, 2022 18:46
@robbles robbles mentioned this pull request Oct 28, 2022
robbles added a commit that referenced this pull request Oct 28, 2022
* DEV-1761: Clean up Ruleset interface (#115)

* remove legacy ruleset types and simplify ruleset interface

* remove unnecessary settings argument from Ruleset interface

* decouple rules.Settings from client API and store settings as strings

* DEV 1761: Add new BoardState and Point fields (#117)

* add Point.TTL, Point.Value, GameState and PointState to BoardState

* allow maps to access BoardState.GameState,PointState

* add PreUpdateBoard and refactor snail_mode with it

* fix bug where an extra turn was printed to the console

* fix formatting

* fix lint errors

Co-authored-by: JonathanArns <jonathan.arns@googlemail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant