DEV 1283: Arcade maze map (#77)

* 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
This commit is contained in:
Rob O'Dwyer 2022-05-31 07:29:34 -07:00 committed by GitHub
parent fff551599a
commit aa38bcd0eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 404 additions and 0 deletions

67
maps/arcade_maze_test.go Normal file
View file

@ -0,0 +1,67 @@
package maps_test
import (
"testing"
"github.com/BattlesnakeOfficial/rules"
"github.com/BattlesnakeOfficial/rules/maps"
"github.com/stretchr/testify/require"
)
func TestArcadeMazeMap(t *testing.T) {
tests := []struct {
boardWidth int
boardHeight int
expectedError error
expectedHazards []rules.Point
}{
{
boardWidth: 19,
boardHeight: 21,
expectedError: nil,
expectedHazards: maps.ArcadeMazeHazards,
},
{
boardWidth: 18,
boardHeight: 21,
expectedError: rules.RulesetError("This map can only be played on a 19X21 board"),
expectedHazards: nil,
},
{
boardWidth: 20,
boardHeight: 21,
expectedError: rules.RulesetError("This map can only be played on a 19X21 board"),
expectedHazards: nil,
},
{
boardWidth: 19,
boardHeight: 20,
expectedError: rules.RulesetError("This map can only be played on a 19X21 board"),
expectedHazards: nil,
},
{
boardWidth: 19,
boardHeight: 22,
expectedError: rules.RulesetError("This map can only be played on a 19X21 board"),
expectedHazards: nil,
},
}
for _, test := range tests {
m := maps.ArcadeMazeMap{}
boardState := rules.NewBoardState(test.boardWidth, test.boardHeight)
settings := rules.Settings{}
editor := maps.NewBoardStateEditor(boardState)
err := m.SetupBoard(boardState, settings, editor)
if test.expectedError != nil {
require.Equal(t, test.expectedError, err)
} else {
require.NoError(t, err)
require.Equal(t, test.expectedHazards, boardState.Hazards)
for _, snake := range boardState.Snakes {
require.Equal(t, 3, len(snake.Body))
}
}
}
}