Add wrapped_constrictor game mode and support for map tags (#102)
* add support for wrapped_constrictor game mode * add tags to map metadata
This commit is contained in:
parent
ffeb401377
commit
b1ddd2f4ca
14 changed files with 46 additions and 5 deletions
11
constants.go
11
constants.go
|
|
@ -39,11 +39,12 @@ const (
|
||||||
ErrorMapNotFound = RulesetError("map not found")
|
ErrorMapNotFound = RulesetError("map not found")
|
||||||
|
|
||||||
// Ruleset / game type names
|
// Ruleset / game type names
|
||||||
GameTypeConstrictor = "constrictor"
|
GameTypeConstrictor = "constrictor"
|
||||||
GameTypeRoyale = "royale"
|
GameTypeRoyale = "royale"
|
||||||
GameTypeSolo = "solo"
|
GameTypeSolo = "solo"
|
||||||
GameTypeStandard = "standard"
|
GameTypeStandard = "standard"
|
||||||
GameTypeWrapped = "wrapped"
|
GameTypeWrapped = "wrapped"
|
||||||
|
GameTypeWrappedConstrictor = "wrapped_constrictor"
|
||||||
|
|
||||||
// Game creation parameter names
|
// Game creation parameter names
|
||||||
ParamGameType = "name"
|
ParamGameType = "name"
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,17 @@ var constrictorRulesetStages = []string{
|
||||||
StageModifySnakesAlwaysGrow,
|
StageModifySnakesAlwaysGrow,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var wrappedConstrictorRulesetStages = []string{
|
||||||
|
StageGameOverStandard,
|
||||||
|
StageMovementWrapBoundaries,
|
||||||
|
StageStarvationStandard,
|
||||||
|
StageHazardDamageStandard,
|
||||||
|
StageFeedSnakesStandard,
|
||||||
|
StageEliminationStandard,
|
||||||
|
StageSpawnFoodNoFood,
|
||||||
|
StageModifySnakesAlwaysGrow,
|
||||||
|
}
|
||||||
|
|
||||||
type ConstrictorRuleset struct {
|
type ConstrictorRuleset struct {
|
||||||
StandardRuleset
|
StandardRuleset
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ func (m ArcadeMazeMap) Meta() Metadata {
|
||||||
MinPlayers: 1,
|
MinPlayers: 1,
|
||||||
MaxPlayers: 6,
|
MaxPlayers: 6,
|
||||||
BoardSizes: FixedSizes(Dimensions{19, 21}),
|
BoardSizes: FixedSizes(Dimensions{19, 21}),
|
||||||
|
Tags: []string{TAG_FOOD_PLACEMENT, TAG_HAZARD_PLACEMENT, TAG_SNAKE_PLACEMENT},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ func (m EmptyMap) Meta() Metadata {
|
||||||
MinPlayers: 1,
|
MinPlayers: 1,
|
||||||
MaxPlayers: 16,
|
MaxPlayers: 16,
|
||||||
BoardSizes: OddSizes(rules.BoardSizeSmall, rules.BoardSizeXXLarge),
|
BoardSizes: OddSizes(rules.BoardSizeSmall, rules.BoardSizeXXLarge),
|
||||||
|
Tags: []string{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,13 @@ import (
|
||||||
"github.com/BattlesnakeOfficial/rules"
|
"github.com/BattlesnakeOfficial/rules"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
TAG_EXPERIMENTAL = "experimental" // experimental map, only available via CLI
|
||||||
|
TAG_SNAKE_PLACEMENT = "snake-placement" // map overrides default snake placement
|
||||||
|
TAG_HAZARD_PLACEMENT = "hazard-placement" // map places hazards
|
||||||
|
TAG_FOOD_PLACEMENT = "food-placement" // map overrides or adds to default food placement
|
||||||
|
)
|
||||||
|
|
||||||
type GameMap interface {
|
type GameMap interface {
|
||||||
// Return a unique identifier for this map.
|
// Return a unique identifier for this map.
|
||||||
ID() string
|
ID() string
|
||||||
|
|
@ -82,6 +89,8 @@ type Metadata struct {
|
||||||
// 2. multiple, fixed sizes (i.e. [11x11, 19x19, 25x25])
|
// 2. multiple, fixed sizes (i.e. [11x11, 19x19, 25x25])
|
||||||
// 3. "unlimited" sizes (the board is not fixed and can scale to any reasonable size)
|
// 3. "unlimited" sizes (the board is not fixed and can scale to any reasonable size)
|
||||||
BoardSizes sizes
|
BoardSizes sizes
|
||||||
|
// Tags is a list of strings use to categorize the map.
|
||||||
|
Tags []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Editor is used by GameMap implementations to modify the board state.
|
// Editor is used by GameMap implementations to modify the board state.
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ func (m InnerBorderHazardsMap) Meta() Metadata {
|
||||||
MinPlayers: 1,
|
MinPlayers: 1,
|
||||||
MaxPlayers: 16,
|
MaxPlayers: 16,
|
||||||
BoardSizes: OddSizes(rules.BoardSizeSmall, rules.BoardSizeXXLarge),
|
BoardSizes: OddSizes(rules.BoardSizeSmall, rules.BoardSizeXXLarge),
|
||||||
|
Tags: []string{TAG_HAZARD_PLACEMENT},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -73,6 +74,7 @@ func (m ConcentricRingsHazardsMap) Meta() Metadata {
|
||||||
MinPlayers: 1,
|
MinPlayers: 1,
|
||||||
MaxPlayers: 16,
|
MaxPlayers: 16,
|
||||||
BoardSizes: OddSizes(rules.BoardSizeSmall, rules.BoardSizeXXLarge),
|
BoardSizes: OddSizes(rules.BoardSizeSmall, rules.BoardSizeXXLarge),
|
||||||
|
Tags: []string{TAG_HAZARD_PLACEMENT},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -114,6 +116,7 @@ func (m ColumnsHazardsMap) Meta() Metadata {
|
||||||
MinPlayers: 1,
|
MinPlayers: 1,
|
||||||
MaxPlayers: 16,
|
MaxPlayers: 16,
|
||||||
BoardSizes: OddSizes(rules.BoardSizeSmall, rules.BoardSizeXXLarge),
|
BoardSizes: OddSizes(rules.BoardSizeSmall, rules.BoardSizeXXLarge),
|
||||||
|
Tags: []string{TAG_HAZARD_PLACEMENT},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -153,6 +156,7 @@ func (m SpiralHazardsMap) Meta() Metadata {
|
||||||
MinPlayers: 1,
|
MinPlayers: 1,
|
||||||
MaxPlayers: 16,
|
MaxPlayers: 16,
|
||||||
BoardSizes: OddSizes(rules.BoardSizeSmall, rules.BoardSizeXXLarge),
|
BoardSizes: OddSizes(rules.BoardSizeSmall, rules.BoardSizeXXLarge),
|
||||||
|
Tags: []string{TAG_HAZARD_PLACEMENT},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -245,6 +249,7 @@ func (m ScatterFillMap) Meta() Metadata {
|
||||||
MinPlayers: 1,
|
MinPlayers: 1,
|
||||||
MaxPlayers: 16,
|
MaxPlayers: 16,
|
||||||
BoardSizes: OddSizes(rules.BoardSizeSmall, rules.BoardSizeXXLarge),
|
BoardSizes: OddSizes(rules.BoardSizeSmall, rules.BoardSizeXXLarge),
|
||||||
|
Tags: []string{TAG_HAZARD_PLACEMENT},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -296,6 +301,7 @@ func (m DirectionalExpandingBoxMap) Meta() Metadata {
|
||||||
MinPlayers: 1,
|
MinPlayers: 1,
|
||||||
MaxPlayers: 16,
|
MaxPlayers: 16,
|
||||||
BoardSizes: OddSizes(rules.BoardSizeSmall, rules.BoardSizeXXLarge),
|
BoardSizes: OddSizes(rules.BoardSizeSmall, rules.BoardSizeXXLarge),
|
||||||
|
Tags: []string{TAG_HAZARD_PLACEMENT},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -410,6 +416,7 @@ func (m ExpandingBoxMap) Meta() Metadata {
|
||||||
MinPlayers: 1,
|
MinPlayers: 1,
|
||||||
MaxPlayers: 16,
|
MaxPlayers: 16,
|
||||||
BoardSizes: OddSizes(rules.BoardSizeSmall, rules.BoardSizeXXLarge),
|
BoardSizes: OddSizes(rules.BoardSizeSmall, rules.BoardSizeXXLarge),
|
||||||
|
Tags: []string{TAG_HAZARD_PLACEMENT},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -485,6 +492,7 @@ func (m ExpandingScatterMap) Meta() Metadata {
|
||||||
MinPlayers: 1,
|
MinPlayers: 1,
|
||||||
MaxPlayers: 16,
|
MaxPlayers: 16,
|
||||||
BoardSizes: OddSizes(rules.BoardSizeSmall, rules.BoardSizeXXLarge),
|
BoardSizes: OddSizes(rules.BoardSizeSmall, rules.BoardSizeXXLarge),
|
||||||
|
Tags: []string{TAG_HAZARD_PLACEMENT},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -567,6 +575,7 @@ Each river has one or two 1-square "bridges" over them`,
|
||||||
MinPlayers: 1,
|
MinPlayers: 1,
|
||||||
MaxPlayers: 12,
|
MaxPlayers: 12,
|
||||||
BoardSizes: FixedSizes(Dimensions{11, 11}, Dimensions{19, 19}, Dimensions{25, 25}),
|
BoardSizes: FixedSizes(Dimensions{11, 11}, Dimensions{19, 19}, Dimensions{25, 25}),
|
||||||
|
Tags: []string{TAG_HAZARD_PLACEMENT, TAG_SNAKE_PLACEMENT},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ func (m HealingPoolsMap) Meta() Metadata {
|
||||||
MinPlayers: 1,
|
MinPlayers: 1,
|
||||||
MaxPlayers: 8,
|
MaxPlayers: 8,
|
||||||
BoardSizes: FixedSizes(Dimensions{7, 7}, Dimensions{11, 11}, Dimensions{19, 19}),
|
BoardSizes: FixedSizes(Dimensions{7, 7}, Dimensions{11, 11}, Dimensions{19, 19}),
|
||||||
|
Tags: []string{TAG_HAZARD_PLACEMENT},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ func TestRegisteredMaps(t *testing.T) {
|
||||||
require.NotZero(t, meta.MaxPlayers, "registered maps must have maximum players declared")
|
require.NotZero(t, meta.MaxPlayers, "registered maps must have maximum players declared")
|
||||||
require.LessOrEqual(t, meta.MaxPlayers, meta.MaxPlayers, "max players should always be >= min players")
|
require.LessOrEqual(t, meta.MaxPlayers, meta.MaxPlayers, "max players should always be >= min players")
|
||||||
require.NotEmpty(t, meta.BoardSizes, "registered maps must have at least one supported size declared")
|
require.NotEmpty(t, meta.BoardSizes, "registered maps must have at least one supported size declared")
|
||||||
|
require.NotNil(t, meta.Tags)
|
||||||
var setupBoardState *rules.BoardState
|
var setupBoardState *rules.BoardState
|
||||||
|
|
||||||
// "fuzz test" supported players
|
// "fuzz test" supported players
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ func (m RoyaleHazardsMap) Meta() Metadata {
|
||||||
MinPlayers: 1,
|
MinPlayers: 1,
|
||||||
MaxPlayers: 16,
|
MaxPlayers: 16,
|
||||||
BoardSizes: OddSizes(rules.BoardSizeSmall, rules.BoardSizeXXLarge),
|
BoardSizes: OddSizes(rules.BoardSizeSmall, rules.BoardSizeXXLarge),
|
||||||
|
Tags: []string{TAG_HAZARD_PLACEMENT},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ func (m SinkholesMap) Meta() Metadata {
|
||||||
MinPlayers: 1,
|
MinPlayers: 1,
|
||||||
MaxPlayers: 8,
|
MaxPlayers: 8,
|
||||||
BoardSizes: FixedSizes(Dimensions{7, 7}, Dimensions{11, 11}, Dimensions{19, 19}),
|
BoardSizes: FixedSizes(Dimensions{7, 7}, Dimensions{11, 11}, Dimensions{19, 19}),
|
||||||
|
Tags: []string{TAG_HAZARD_PLACEMENT},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ func (m SoloMazeMap) Meta() Metadata {
|
||||||
Dimensions{19, 21},
|
Dimensions{19, 21},
|
||||||
Dimensions{25, 25},
|
Dimensions{25, 25},
|
||||||
),
|
),
|
||||||
|
Tags: []string{TAG_EXPERIMENTAL, TAG_FOOD_PLACEMENT, TAG_HAZARD_PLACEMENT, TAG_SNAKE_PLACEMENT},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ func (m StandardMap) Meta() Metadata {
|
||||||
MinPlayers: 1,
|
MinPlayers: 1,
|
||||||
MaxPlayers: 16,
|
MaxPlayers: 16,
|
||||||
BoardSizes: OddSizes(rules.BoardSizeSmall, rules.BoardSizeXXLarge),
|
BoardSizes: OddSizes(rules.BoardSizeSmall, rules.BoardSizeXXLarge),
|
||||||
|
Tags: []string{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -144,6 +144,8 @@ func (rb rulesetBuilder) Ruleset() PipelineRuleset {
|
||||||
stages = append(stages, standardRulesetStages[1:]...)
|
stages = append(stages, standardRulesetStages[1:]...)
|
||||||
case GameTypeConstrictor:
|
case GameTypeConstrictor:
|
||||||
stages = append(stages, constrictorRulesetStages[1:]...)
|
stages = append(stages, constrictorRulesetStages[1:]...)
|
||||||
|
case GameTypeWrappedConstrictor:
|
||||||
|
stages = append(stages, wrappedConstrictorRulesetStages[1:]...)
|
||||||
case GameTypeRoyale:
|
case GameTypeRoyale:
|
||||||
stages = append(stages, royaleRulesetStages[1:]...)
|
stages = append(stages, royaleRulesetStages[1:]...)
|
||||||
case GameTypeSolo:
|
case GameTypeSolo:
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,7 @@ func TestRulesetBuilder(t *testing.T) {
|
||||||
{GameType: rules.GameTypeRoyale},
|
{GameType: rules.GameTypeRoyale},
|
||||||
{GameType: rules.GameTypeSolo},
|
{GameType: rules.GameTypeSolo},
|
||||||
{GameType: rules.GameTypeConstrictor},
|
{GameType: rules.GameTypeConstrictor},
|
||||||
|
{GameType: rules.GameTypeWrappedConstrictor},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, expected := range expectedResults {
|
for _, expected := range expectedResults {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue