Commit graph

43 commits

Author SHA1 Message Date
Rob O'Dwyer
1c728faeca
prevent negative hazard damage from healing past max health (#91) 2022-06-30 12:10:30 -07:00
Rob O'Dwyer
426da8ac5e
reorder built-in ruleset stages so game over is checked first (#79) 2022-06-01 15:21:27 -07:00
Rob O'Dwyer
1adbc79168
DEV 953: Add basic maps support to CLI (#74)
* 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
2022-05-25 11:24:27 -07:00
Torben
3bd1e47bb4
change all "int32" types to "int" (#75) 2022-05-25 11:17:41 -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
Torben
397d925110
DEV-765 pipeline refactor (#64)
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.
2022-03-16 16:58:05 -07:00
bvanvugt
020303a8dd Isolate and improve logic to determine default move. 2022-01-11 22:44:37 +00: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
Rob O'Dwyer
e416384007
Refactor RoyaleRuleset and move hazard damage into StandardRuleset (#50)
* move hazard damage into StandardRuleset

* OutOfBounds -> Hazards

* remove "out of bounds" in comment

* add cases for eating food to hazard damage test
2021-08-17 16:47:06 -07:00
bvanvugt
72a74a9628 Remove ruleset versions for GitHub release version (future). 2021-07-02 20:09:55 -07:00
John Oram
f31bdff4b8
add ruleset data to the calls made by the cli (name and version) (#32)
* add ruleset data to the cli (name and version)
* remove double ruleset tracking with royale mode
2021-07-02 20:00:19 -07:00
bvanvugt
d62807774b Invert the Y-Axis to match modern gameplay. 2021-01-19 15:33:05 -08:00
bvanvugt
accb598e29 Add RulesetError test case.
Remove old comments.
2020-12-11 10:05:19 -08:00
md-hexdrive
2cbf8884bf
Add new constants for standard ruleset errors, resolves #5 (#24)
* Convert errors to constant error interfaces.
2020-12-11 09:50:52 -08:00
Brad Van Vugt
e01a1bf505
"Feast" -> "Maze". Fix backfill bug. (#26) 2020-12-08 13:20:13 -08:00
bvanvugt
ca4b6c5dce Add parameters for food spawn chance and min food. 2020-11-20 12:00:58 -08:00
bvanvugt
c6d9ba12ab Never spawn food within one move of any snake. 2020-11-10 13:00:13 -08:00
Brad Van Vugt
f5aec61e04 Rename "EliminatedByStarvation" > "EliminatedByOutOfHealth" 2020-09-10 12:00:56 -07:00
Brad Van Vugt
92592c2aba Allow previous game state to include eliminated snakes. Fixes #19. 2020-09-10 11:49:41 -07:00
Brad Van Vugt
a342f87ed6 Ensure snakes eating on their last turn survive! 2020-08-31 13:18:03 -07:00
Brad Van Vugt
5aec70de2b Prioritize self-collisions over other collisions. Fixes #16. 2020-07-21 17:11:12 -07:00
Brad Van Vugt
d0400fcb18 Always spawn food within two moves of each snake on known board sizes. 2020-07-21 13:43:28 -07:00
sjbcastro
70a8107a6f
Implemented TestCreateNextBoardState (#15) 2020-05-28 11:26:44 -07:00
sjbcastro
2d62a58c9b
Made snakes spawn on odd or even diagonal points (#14). Fixes #12.
Randomly placed snakes will now always spawn on "even" squares.
2020-05-26 15:07:43 -07:00
Brad Van Vugt
71fc6bf503 Add game over detection to each ruleset. 2020-05-17 14:22:09 -07:00
Brad Van Vugt
44b6b94666
Add TeamRuleset (#13)
This builds on work done by @dlsteuer in #10
2020-02-20 10:24:44 -08:00
Brad Van Vugt
8153585f57
Add "EliminatedBy" to snake eliminations. (#11)
* add eliminated by

* add test

* make sure largest snake is listed as eliminator on head to head collisions

* remove unused type def

* Reduce memory usage during elimination checks.

Co-authored-by: Daniel Steuernol <dlsteuer@gmail.com>
2020-02-19 11:44:48 -08:00
Brad Van Vugt
a241c526b2 Merge branch 'master' of github.com:BattlesnakeOfficial/rules 2020-02-19 11:15:10 -08:00
Brad Van Vugt
021b363822 Add comment to make sure random spawns are always same color. 2020-02-19 11:15:03 -08:00
bvanvugt
ccd7a4e47d Maintain at least 1 food on board at all times. 2020-02-01 10:47:15 -08:00
bvanvugt
6edb4ce5d4 Reduce standard food spawn to a 15% chance. 2020-01-15 16:42:43 -08:00
bvanvugt
d7b4663ef4 Bump food spawn rate to better match previous algorithm. 2020-01-14 16:39:41 -08:00
bvanvugt
60c0b149ba Merge branch 'master' of github.com:BattlesnakeOfficial/rules 2020-01-09 13:59:03 -08:00
bvanvugt
20c42a7a72 Constant whitespace. 2020-01-09 13:58:49 -08:00
Brad Van Vugt
9c13dea6c0 Add error cases to standard move resolution. 2020-01-05 21:03:54 -08:00
Brad Van Vugt
7854e11e51 Package name rulesets -> rules. 2020-01-05 17:08:05 -08:00
Brad Van Vugt
72b6d78c93 More test coverage. 2020-01-03 12:56:33 -08:00
Brad Van Vugt
7d29514b6c More test coverage for StandardRuleset. 2020-01-03 11:39:19 -08:00
bvanvugt
010b3aa08f Rename consts, remove pointers where not wanted/needed, snake placement tests. 2020-01-02 16:10:33 -08:00
bvanvugt
53d57d8e6a Update README 2020-01-01 23:10:49 -08:00
Brad Van Vugt
29a8fd1dd4
Update standard.go 2020-01-01 17:23:01 -08:00
Brad Van Vugt
321b67239a
Create standard.go 2019-12-31 20:43:23 -08:00