2023-08-03 21:07:58 +02:00
|
|
|
package maze
|
|
|
|
|
2023-08-05 11:20:53 +02:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2023-08-04 19:11:26 +02:00
|
|
|
type Coordinates struct {
|
|
|
|
X, Y int
|
|
|
|
}
|
|
|
|
type Node struct {
|
|
|
|
Coords Coordinates
|
|
|
|
Up, Down *Node
|
|
|
|
Left, Right *Node
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewNode(coords Coordinates) *Node {
|
|
|
|
return &Node{
|
|
|
|
Coords: coords,
|
|
|
|
Up: nil,
|
|
|
|
Down: nil,
|
|
|
|
Left: nil,
|
|
|
|
Right: nil,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-05 10:38:46 +02:00
|
|
|
type RawMaze struct {
|
|
|
|
PathChar, WallChar byte
|
|
|
|
Data []string
|
|
|
|
}
|
|
|
|
|
2023-08-05 11:20:53 +02:00
|
|
|
func (m *RawMaze) String() string {
|
|
|
|
var ret strings.Builder
|
|
|
|
ret.WriteString("{\n")
|
|
|
|
ret.WriteString(fmt.Sprintf("\tPathChar: %v,\n", m.PathChar))
|
|
|
|
ret.WriteString(fmt.Sprintf("\tWallChar: %v,\n", m.WallChar))
|
|
|
|
ret.WriteString("\tData: \n")
|
|
|
|
for _, line := range m.Data {
|
|
|
|
ret.WriteRune('\t')
|
|
|
|
ret.WriteRune('\t')
|
|
|
|
ret.WriteString(line)
|
|
|
|
ret.WriteRune('\n')
|
|
|
|
}
|
|
|
|
ret.WriteString("}")
|
|
|
|
|
|
|
|
return ret.String()
|
|
|
|
}
|
|
|
|
|
2023-08-04 19:11:26 +02:00
|
|
|
type Maze struct {
|
|
|
|
Width, Height uint
|
|
|
|
Nodes []*Node
|
2023-08-03 21:07:58 +02:00
|
|
|
}
|
|
|
|
|
2023-08-04 19:11:26 +02:00
|
|
|
type SolvedMaze struct {
|
2023-08-03 21:07:58 +02:00
|
|
|
Maze
|
2023-08-04 19:11:26 +02:00
|
|
|
Solution []*Node
|
2023-08-03 21:07:58 +02:00
|
|
|
}
|