Documentation ¶
Overview ¶
Package grid defines a simple 2-D grid maze type.
Index ¶
- type Maze
- func (m *Maze) AccessibleNeighbors(i int) (result []int)
- func (m *Maze) Height() int
- func (m *Maze) N() int
- func (m *Maze) Neighbors(i int) (result []int)
- func (m *Maze) Wall(i, j int) *bool
- func (m *Maze) WallAbove(x, y int) *bool
- func (m *Maze) WallLeftOf(x, y int) *bool
- func (m *Maze) Width() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Maze ¶
type Maze struct {
// contains filtered or unexported fields
}
A Maze is a maze with square cells in a rectangular grid.
func Example ¶
func Example() *Maze
Example returns a connected maze without loops of size 6x5. See example.png in the source directory.
func NewMaze ¶
NewMaze creates a new maze with the given width and height and all walls set or not set, depending on parameter setWalls.
func (*Maze) AccessibleNeighbors ¶
AccessibleNeighbors returns those neighbors of node i where there's no wall between i and the neighbor node.
func (*Maze) Wall ¶
Wall returns a pointer to the bool that determines if there's a wall between cells i and j.
func (*Maze) WallAbove ¶
WallAbove returns a pointer to the boolean for the wall above the cell at (x,y). For the walls below the last row, use y == Height().
func (*Maze) WallLeftOf ¶
WallLeftOf returns a pointer to the boolean for the wall left of the cell at (x,y). For the wall to the right of the last column, use x == Width().