Commit graph

17 commits

Author SHA1 Message Date
Rob O'Dwyer
82e1999126
DEV-1761: New rules API (#118)
* 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>
2022-10-28 16:49:49 -07:00
Rob O'Dwyer
e6e36ce46f
DEV-1703: Avoid spawning food on hazards for islands and bridges map (#112)
* move PlaceFoodFixed and PlaceSnakesInQuadrants to maps package

* don't spawn food on hazards in islands/rivers and bridges maps
2022-09-22 16:09:01 -07:00
Chris Hoefgen
f82cfe5309
Rivers and Bridges map refactor (#103)
* Separated out rivers and bridges into its own file with three map variants

* fixing tags

* removed extra 4 starting positions from the medium map since it only supports 8 players

* update GetUnoccupiedPoints to consider hazards with a flag

* use new utility method to fine unoccupied points and enforce map sizes

* changed up casting to make IsAllowable() more usable
2022-08-19 10:09:04 -07:00
Torben
e1289af5fb
DEV-1479 ensure snake elimination turn is set (#93)
* ensure snake elimination turn is set

- centralise elimination update logic to a single place to ensure consistency

* doc the method

* testing
2022-07-21 14:26:56 -07:00
Torben
663c377cc4
change map support for large #'s of snakes (#92)
* change map support for large #'s of snakes

* test square board fn

* format comment

* add whitespace

* better support large #'s of snakes on small boards

* include an intermediate xlarge size
2022-07-07 11:14:30 -07:00
Torben
61aeee31d6
allow placement of up to 16 snakes on xlarge board (#90) 2022-06-29 14:26:18 -07:00
Torben
9d6b1147cd
fix for rivers and bridges snake start positions (#85)
* fix for rivers and bridges snake start positions

* update max player count, add unit test

* set player count to 12 (max for smallest size)

* fix: one of the 19x19 spawn points

* randomize snake placement at start positions

* randomly choose starts in quadrants

* fix: check that start positions are valid

* modify food placement to avoid hazards
2022-06-28 14:41:01 -07:00
Torben
f58df66e69
allow initial food placement for 8 snakes on 7x7 board (#87)
* allow initial food placement for 8 snakes on 7x7

* fix logic to be for small board

* fix inverted logic

* logic should be actually <= 4 snakes, not 7
2022-06-22 16:14:15 -07:00
Torben
3bd1e47bb4
change all "int32" types to "int" (#75) 2022-05-25 11:17:41 -07:00
Rob O'Dwyer
e94d758a9b
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
2022-05-17 15:45:56 -07:00
Rob O'Dwyer
dab9178a55
DEV 1247: Add a new map generator interface (#71)
* reorganize code

* first draft of map generator interfaces

* add explicit random interface to board helpers

* implement standard map

* rename Generator to GameMap

* allow initializing snakes separately from placing them

* add random number generator to Settings

* updates to GameMap interface

* add helpers for creating and updating BoardState with maps
2022-05-11 08:26:28 -07:00
Torben
d378759d58
DEV-1096 - add a new "pipeline" concept (#67)
* add a new "pipeline" concept

- added new Pipeline type which is a series of stages
- added a global registry to facilitate plugin architecture
- 100% test coverage

* Refactor rulesets to provide and use Pipeline

* fix copypasta comments

* fix lint for unused method

* include game over stages in ruleset pipelines

* clean up unused private standard methods

* remove unused private methods in squad ruleset

* remove unused private methods in royale ruleset

* refactor: pipeline clone + return next board state

* YAGNI: remove unused Append

* refactor: improve stage names

* add no-op behavior to stages for initial state

* refactor: no-op decision within stage functions

* remove misleading comment that isn't true

* dont bother checking for init in gameover stages

* remove redundant test

* refactor: provide a combined ruleset/pipeline type

* fix: movement no-op for GameOver check

IsGameOver needs to run pipeline, move snakes needs to no-op for that

* add test coverage

* refactor: improve stage names and use constants

* add Error method

Support error checking before calling Execute()

* update naming to be American style

* panic when overwriting stages in global registry

* rename "Error" method and improve docs

* use testify lib for panic assertion

* remove redundant food stage

* use ruleset-specific logic for game over checks

* re-work Pipeline errors

* rework errors again

* add defensive check for zero length snake

* use old logic which checks current state, not next

* add warning about how PipelineRuleset checks for game over
2022-04-19 15:52:57 -07:00
Brad Van Vugt
573a93fa30
Stop spawning food in corners in competitive play. (#68) 2022-04-07 07:59:21 -07:00
bvanvugt
6e01793750 Remove equidistant food spawns that are closer to center. 2022-01-18 20:51:01 +00:00
bvanvugt
4df2c65432 Restrict fixed food spawns to only locations further from center. 2022-01-18 20:21:21 +00:00
Rob O'Dwyer
e9f408cdbb
add turn to BoardState and remove it from RoyaleRuleset (#52) 2021-08-27 13:28:12 -07:00
Rob O'Dwyer
015b681f14
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
2021-08-23 17:13:58 -07:00