// floodfill starts from some coordinate, and randomly moves(floodfills) neighboring coordinates if unexplored. // This is used to create deadends. func (m *Maze) floodfill(c, from common.Coordinate, explored map[common.Coordinate]bool) { m.sealRoom(c) m.removeWallBetween(c, from) explored[c] = true nbs := c.Neighbors() idxs := rand.Perm(len(nbs)) for _, idx := range idxs { nb := nbs[idx] if m.contains(nb) && !explored[nb] { m.floodfill(nb, c, explored) } } }