DEV-1313: Add additional map types (#76)

* 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
This commit is contained in:
Torben 2022-06-01 11:39:31 -07:00 committed by GitHub
parent aa38bcd0eb
commit f0dc0bcb38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 1129 additions and 24 deletions

View file

@ -1,19 +1,20 @@
package maps
package maps_test
import (
"fmt"
"testing"
"github.com/BattlesnakeOfficial/rules"
"github.com/BattlesnakeOfficial/rules/maps"
"github.com/stretchr/testify/require"
)
func TestStandardMapInterface(t *testing.T) {
var _ GameMap = StandardMap{}
var _ maps.GameMap = maps.StandardMap{}
}
func TestStandardMapSetupBoard(t *testing.T) {
m := StandardMap{}
m := maps.StandardMap{}
settings := rules.Settings{}
tests := []struct {
@ -143,7 +144,7 @@ func TestStandardMapSetupBoard(t *testing.T) {
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
nextBoardState := rules.NewBoardState(test.initialBoardState.Width, test.initialBoardState.Height)
editor := NewBoardStateEditor(nextBoardState)
editor := maps.NewBoardStateEditor(nextBoardState)
settings := settings.WithRand(test.rand)
err := m.SetupBoard(test.initialBoardState, settings, editor)
@ -158,7 +159,7 @@ func TestStandardMapSetupBoard(t *testing.T) {
}
func TestStandardMapUpdateBoard(t *testing.T) {
m := StandardMap{}
m := maps.StandardMap{}
tests := []struct {
name string
@ -303,7 +304,7 @@ func TestStandardMapUpdateBoard(t *testing.T) {
t.Run(test.name, func(t *testing.T) {
nextBoardState := test.initialBoardState.Clone()
settings := test.settings.WithRand(test.rand)
editor := NewBoardStateEditor(nextBoardState)
editor := maps.NewBoardStateEditor(nextBoardState)
err := m.UpdateBoard(test.initialBoardState.Clone(), settings, editor)