Castle Wall Hazard Map (#101)

* castle_wall map

Wall of hazards around the board with dangerous bridges.

- add support for all standard board sizes
- hazard placement for all board sizes

* passage food placement for all board sizes

* 4 snake starting positions for all maps

* only one food can spawn on a bridge

* support 8 snakes for all board sizes

support 12 snakes on XLarge and XXLarge board sizes

* max 2 food sm/med/lg and max 4 food on xlg/xxlg

no food in the first 10 turns

* sort generated hazard positions

* remove 'uninteresting' castle wall map board sizes

* refactor castle wall map to align with #103

* align map castle wall meta Name with ID

* set MinPlayers to 1 for castle wall map

* pass max snake/food and startPosition to priv func

* fix castle wall food placement and refactor tests

* avoid food spawn by snake heads on castle wall map

- fixes forced food spawning infront of snake issue on large & xlarge maps with double walls
This commit is contained in:
Blayne Campbell 2022-08-26 10:11:19 -06:00 committed by GitHub
parent 2668788683
commit ba3b882e1b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 747 additions and 0 deletions

42
maps/castle_wall_test.go Normal file
View file

@ -0,0 +1,42 @@
package maps_test
import (
"testing"
"github.com/BattlesnakeOfficial/rules"
"github.com/BattlesnakeOfficial/rules/maps"
"github.com/stretchr/testify/require"
)
func TestCastleWallHazardsMap(t *testing.T) {
// check error handling
m := maps.CastleWallMediumHazardsMap{}
settings := rules.Settings{}
// check error for unsupported board sizes
state := rules.NewBoardState(7, 7)
editor := maps.NewBoardStateEditor(state)
err := m.SetupBoard(state, settings, editor)
require.Error(t, err)
tests := []struct {
Map maps.GameMap
Width uint
Height uint
}{
{maps.CastleWallMediumHazardsMap{}, 11, 11},
{maps.CastleWallLargeHazardsMap{}, 19, 19},
{maps.CastleWallExtraLargeHazardsMap{}, 25, 25},
}
// check all the supported sizes
for _, test := range tests {
state = rules.NewBoardState(int(test.Width), int(test.Height))
state.Snakes = append(state.Snakes, rules.Snake{ID: "1", Body: []rules.Point{}})
editor = maps.NewBoardStateEditor(state)
require.Empty(t, state.Hazards)
err = test.Map.SetupBoard(state, settings, editor)
require.NoError(t, err)
require.NotEmpty(t, state.Hazards)
}
}