grid

package
v0.0.0-...-8702b40 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2017 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package grid defines a simple 2-D grid maze type.

Index

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

func NewMaze(width, height int, setWalls bool) *Maze

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

func (m *Maze) AccessibleNeighbors(i int) (result []int)

AccessibleNeighbors returns those neighbors of node i where there's no wall between i and the neighbor node.

func (*Maze) Height

func (m *Maze) Height() int

Height returns the number of cells along the y axis.

func (*Maze) N

func (m *Maze) N() int

N returns the number of cells.

func (*Maze) Neighbors

func (m *Maze) Neighbors(i int) (result []int)

Neighbors returns the neighboring cells of cell i.

func (*Maze) Wall

func (m *Maze) Wall(i, j int) *bool

Wall returns a pointer to the bool that determines if there's a wall between cells i and j.

func (*Maze) WallAbove

func (m *Maze) WallAbove(x, y int) *bool

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

func (m *Maze) WallLeftOf(x, y int) *bool

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().

func (*Maze) Width

func (m *Maze) Width() int

Width returns the number of cells along the x axis.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL