maze

package
v0.0.0-...-89ad80c Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2019 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cell

type Cell struct {
	// contains filtered or unexported fields
}

Cell a point in a maze

func CreateCell

func CreateCell(x, y int) *Cell

CreateCell creates a new cell at position {x,y}

func (Cell) Draw

func (c Cell) Draw(d Drawing)

Draw draws a cell onto a drawing

func (c *Cell) Link(cells [][]*Cell)

Link populates the edges of the cell with other cells or edges

func (Cell) String

func (c Cell) String() string

type CellNeighbor

type CellNeighbor struct {
	// contains filtered or unexported fields
}

CellNeighbor neighboring cell in a maze

func (CellNeighbor) String

func (n CellNeighbor) String() string

type Drawing

type Drawing struct {
	Context   *gg.Context
	CellWidth int
}

Drawing draws a maze

func CreateDrawing

func CreateDrawing(width, height, cellWidth int) Drawing

CreateDrawing create a drawing given dimensions and a cell size

func (Drawing) Save

func (d Drawing) Save(filename string)

Save saves a drawing to disk given a filename

func (*Drawing) String

func (d *Drawing) String() string

type Edge

type Edge struct {
	// contains filtered or unexported fields
}

Edge represents the edge between two cells in the maze

func (Edge) String

func (e Edge) String() string

type Maze

type Maze struct {
	// contains filtered or unexported fields
}

Maze is a 2d grid of cells with possible walls between each cell

func Create

func Create(width int, height int, solverType SolverType) Maze

Create creates a maze of dimension {width, height}

func (*Maze) Save

func (m *Maze) Save(fileName string)

Save draw the maze and save to the provided filename

func (Maze) String

func (m Maze) String() string

type Neighbors

type Neighbors struct {
	// contains filtered or unexported fields
}

Neighbors holds the neighboring cells of a cell

type Solver

type Solver struct {
	// contains filtered or unexported fields
}

Solver builds a maze using various rules

func CreateSolver

func CreateSolver(solverType SolverType, cells []*Cell) Solver

CreateSolver Creates a solver struct

func (*Solver) GenerateMaze

func (s *Solver) GenerateMaze()

GenerateMaze Creates a maze using a solver type

type SolverType

type SolverType int

SolverType types of solvers for mazes

const (
	GrowingTreeNewest SolverType = iota + 1
	GrowingTreeRandom
	GrowingTree50Split
)

SolverType types of solvers for mazes

func (SolverType) String

func (i SolverType) String() string

Jump to

Keyboard shortcuts

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