* add 'map' cli command
- provides the following map information functions:
- list all available maps in the global registry
- display map metadata
- update docs with map command examples
* add list and info subcommands to map cli command
* rename map command list and info factory functions
* add --all flag to map info subcommand
* handle cmd.Help error
Previously the CLI would exit immediately with an error if a snake
returned a response with invalid JSON.
Now the CLI continues running the game and a snake with an invalid
response continues in the direction of it's last move.
Also logs a warning with details about the invalid response. Where
possible, the log includes the response body in case it contains helpful
info.
* 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
* Commit from Stream
We got the maze working decently well!
Started off with exploring the repo a bit and getting used to the Map
stuff
The Maze is working pretty well except the mazes that are generated
aren't actually complete-able yet. They end up creating spaces that are
blocked off from the rest of the map
The maze generation algo is based off 'Recursive division method' mostly
following this Wiki
This looked to always create a 'valid' maze, while mine doesn't so need
to figure out what my bug is, cause I'm pretty sure there is one!
* I think we got maze generation working!
Did a lot, should have commited more lol
Got map generation working where I can see it go frame by frame, and
think we squashed the last few bugs with wall generation and hole
cutting
Now need it to actually make a new maze when you finish this first one
* We can run on a bigger board now, and we place the food randomly on the board after you grab it the first time
* Make sure my health is always 100 so don't have to worry about that lol
* Fix placing of food on maze to NOT be on an existing hazard and after 3 foods make a new maze
* Maze generation works better now and a bit of cleanup
* Committing old code
* Got state saving as Hazards Bits Working well, I think whats up next is making the map grow each level
* Draw maze in the center of the board, the maze grows as you complete levels until it fills the entire board
* Ran go fmt
* Remove my little debugging script that I added
* Revert changes I made initially to the map interface
* Move my copy-pasted printMap function to my map specifically
* Go fmt
* Write some doc comments and fix some weird code artifacts
* A few more comments and one last go fmt
* Cut less holes, this makes the maze more exciting
* Add version to Metadata and go fmt again
* Can collapse this down
* Random food spawns are more fun for sure
* add minimal support for serving a game to the board UI
* We did 3 main things here:
- Fixed the bug where hazards were getting multi-stacked
- Fixed the bug where the food could spawn on top of the snake head
- Fixed the lint errors
* Games aren't infinite now, they end by not spawning a food when you have reached a certain number of turns at the max board size
* Extract some functions to make deciding when the game is over easier
* Get evil mode implemented to force the game to end
* Fix small bugs about where we spawned the food in evil mode
* Have the snake keep growing by adding tail segments to match the current level. We start at two length because 1 lenth snakes look weird on the board since they don't have a neck to orient themselves. Here we also fix a bug where evil mode was trying to place food off the map
* Run go fmt
* Add the missing meta-data pieces
* Support a smaller board without the change of infinite loops and change the name of the maze
* Rename the actual struct and fix the tests to not make extra snakes when the map doesn't support it
* Revert "add minimal support for serving a game to the board UI"
This reverts commit 0ac3592c7669ab1bccd7bd3322adffbef5e911ce.
* add minimal support for serving a game to the board UI
* Cleanup and extract and function to place food so we don't have basically the same body twice. This also will prevent the initial food spawn from being right next to the snake
* Revert "add minimal support for serving a game to the board UI"
This reverts commit c1a3b134213dabf44df56e3ca1e6d30ff8aaa516.
* Fix lint
* 2 length snakes are silly, so lets start with 3 each time
* We start out with 3 length snakes, and a fixed set of map sizes
Co-authored-by: Rob O'Dwyer <odwyerrob@gmail.com>
* add minimal support for serving a game to the board UI
* refactor into new board package
* support reporting errors and author names to board
* support passing an alternate board URL
* avoid using IPv6 for local URL
* use rules.Point instead of a custom Point type for board package
* use zero for generic communication error code in cli
* rename createGameEvent to buildFrameEvent
* tests for conversion from boardState/snakeState to game frame
* 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
* 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
* WIP: initial data model for new meta props
* WIP: implemented new props
* test and bug fix:
- add coverage of players and sizes
- fix unlimited map size bug
* FIX: update supported players for arcade to 6
* fix: test should be min -> max, not max->max
* Change some naming and the FixedSizes function
* update comment to reflect API changes
* improve comment clarity
* rename field for improved clarity
* change some more "map" -> "board" wording
* add helper to draw a ring of hazards
* refactor tests to not be internal tests
* add "hz_inner_wall" map
* add "hz_rings" map
* fix map registry
* fix: edge case bugs in drawRing
* remove println
* add "hz_columns"
* add "hz_rivers_bridges" map
* WIP: implementing spiral hazards map
* finish basic testing of 'hz_spiral'
* include first turn
* add "hz_hazards" map
* remove incorrect author
* add "hz_grow_box" map
* add "hz_expand_box" map
* add "hz_expand_scatter" map
* remove debug
* document the new "Range" method
* - use rules.RulesetError instead of generic error
- use a rules.Point for map rivers and bridgets map key
* use rules.RulesetError instead of errors.New
* provide more detail about boundar conditions
* fix documentation (max can be == min)
* add unit tests
* add "namcap" map
* adjust hazards and starting food positions
* add food randomly, not on top of hazards
* add exits on the top and bottom
* rename to arcade_maze
* add maps README
* test for ArcadeMazeMap
* adjustments to hazards in arcade_maze
* remove squad support and switch to using pipelines only in RulesBuilder
* remove spawn_food.standard from legacy ruleset definitions
* bugfix: Royale map generates Standard food
* add maps support to CLI
* add automated tests for all registered GameMap implementations
* update README
* 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
* 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
- Update usage section in the README with the latest flags.
- Update default sample output (BoardState fields have changed,
OutOfBounds has been removed).
- Add section describing options for getting JSON output with the
`--output` and `--debug-requests` flag.
Refactor rulesets into smaller composable operations
In order to mix up the functionality from different rulesets like Solo, Royale, etc. the code in these classes needs to be broken up into small functions that can be composed in a pipeline to make a custom game mode.