2023-08-05 11:25:32 +02:00
|
|
|
package maze
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
type RawMaze struct {
|
|
|
|
PathChar, WallChar byte
|
|
|
|
Data []string
|
|
|
|
}
|
|
|
|
|
|
|
|
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-05 12:02:42 +02:00
|
|
|
|
|
|
|
func (m *RawMaze) isPath(x int, y int) bool {
|
|
|
|
return m.Data[y][x] == m.PathChar
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *RawMaze) isWall(x int, y int) bool {
|
|
|
|
return m.Data[y][x] == m.WallChar
|
|
|
|
}
|