adventofcode/2019/day20/maze.go

43 lines
863 B
Go

package main
import (
"fmt"
h "git.bullercodeworks.com/brian/adventofcode/helpers"
)
type MazeMap map[h.Coordinate3d]bool
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)
} else {
fmt.Print(".")
}
} else {
fmt.Print("#")
}
}
fmt.Println()
}
}