adventofcode/2019/day20/maze.go

43 lines
863 B
Go
Raw Normal View History

2020-11-03 11:02:36 +00:00
package main
import (
"fmt"
2020-11-03 21:09:13 +00:00
h "git.bullercodeworks.com/brian/adventofcode/helpers"
2020-11-03 11:02:36 +00:00
)
2020-11-03 21:09:13 +00:00
type MazeMap map[h.Coordinate3d]bool
2020-11-03 11:02:36 +00:00
2020-11-03 21:09:13 +00:00
type Maze struct {
MazeMap
Outer Square
Inner Square
Portals map[h.Coordinate3d]Portal
Start h.Coordinate3d
End h.Coordinate3d
}
func (m *Maze) Print(visited map[h.Coordinate3d]bool) {
for y := m.Outer.Tl.Y - 1; y < m.Outer.Br.Y+1; y++ {
for x := m.Outer.Tl.X - 1; x < m.Outer.Br.X+1; x++ {
c := h.Coordinate3d{X: x, Y: y, Z: 0}
if _, pok := m.Portals[c]; pok {
fmt.Print("*")
//} else if m.Inner.IsInBorder(c) {
// fmt.Print("$")
//} else if m.Inner.ContainsButNotBorder(c) {
// fmt.Print(" ")
} else if m.MazeMap[c] {
if v, ok := visited[c]; ok && v {
fmt.Print(h.FILL_CHAR)
2020-11-03 11:02:36 +00:00
} else {
2020-11-03 21:09:13 +00:00
fmt.Print(".")
2020-11-03 11:02:36 +00:00
}
2020-11-03 21:09:13 +00:00
} else {
fmt.Print("#")
2020-11-03 11:02:36 +00:00
}
}
fmt.Println()
}
}