allow initial food placement for 8 snakes on 7x7 board (#87)
* allow initial food placement for 8 snakes on 7x7 * fix logic to be for small board * fix inverted logic * logic should be actually <= 4 snakes, not 7
This commit is contained in:
parent
5ecc285dcd
commit
f58df66e69
2 changed files with 81 additions and 48 deletions
|
|
@ -8,6 +8,34 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestDev1235(t *testing.T) {
|
||||
// Small boards should no longer error and only get 1 food when num snakes > 4
|
||||
state, err := CreateDefaultBoardState(MaxRand, BoardSizeSmall, BoardSizeSmall, []string{
|
||||
"1", "2", "3", "4", "5", "6", "7", "8",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, state.Food, 1)
|
||||
state, err = CreateDefaultBoardState(MaxRand, BoardSizeSmall, BoardSizeSmall, []string{
|
||||
"1", "2", "3", "4", "5",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, state.Food, 1)
|
||||
|
||||
// Small boards with <= 4 snakes should still get more than just center food
|
||||
state, err = CreateDefaultBoardState(MaxRand, BoardSizeSmall, BoardSizeSmall, []string{
|
||||
"1", "2", "3", "4",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, state.Food, 5)
|
||||
|
||||
// Medium boards should still get 9 food
|
||||
state, err = CreateDefaultBoardState(MaxRand, BoardSizeMedium, BoardSizeMedium, []string{
|
||||
"1", "2", "3", "4", "5", "6", "7", "8",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, state.Food, 9)
|
||||
}
|
||||
|
||||
func sortPoints(p []Point) {
|
||||
sort.Slice(p, func(i, j int) bool {
|
||||
if p[i].X != p[j].X {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue