extend spec for generating with complexity

master
bel 2023-07-16 14:07:14 -06:00
parent 95fe38699b
commit 6a5a3f1016
4 changed files with 34 additions and 5 deletions

24
src/game/maze/generate.go Normal file
View File

@ -0,0 +1,24 @@
package maze
type Maze struct {
Rows []Row
}
type Row []Room
type Room struct {
Top bool
Left bool
Right bool
Bottom bool
}
/*
1. generate start=>finish
1. complexity to determine how many paths [0..100 for % of rooms/2]
1. randomly choose a start point
1. simulated annealing to generate paths straight vs turn vs end
*/
func Generate(spec Spec) Maze {
return Maze{}
}

View File

@ -0,0 +1 @@
package maze_test

View File

@ -5,17 +5,19 @@ type Spec struct {
W uint16
H uint16
}
Complexity byte
Seed uint32
}
func NewSpec(w, h uint16) Spec {
return NewSpecWithSeed(w, h, NewSeed())
func NewSpec(w, h uint16, complexity byte) Spec {
return NewSpecWithSeed(w, h, complexity, NewSeed())
}
func NewSpecWithSeed(w, h uint16, seed uint32) Spec {
func NewSpecWithSeed(w, h uint16, complexity byte, seed uint32) Spec {
result := Spec{}
result.Size.W = w
result.Size.H = h
result.Complexity = complexity
result.Seed = seed
return result
}

View File

@ -7,11 +7,13 @@ import (
)
func TestNewSpec(t *testing.T) {
spec := maze.NewSpec(8, 6)
spec := maze.NewSpec(8, 6, 2)
if got := spec.Size.W; got != 8 {
t.Error(got)
} else if got := spec.Size.H; got != 6 {
t.Error(got)
} else if got := spec.Complexity; got != 2 {
t.Error(got)
} else if got := spec.Seed; got == 0 {
t.Error(got)
}