package module
Version: v0.0.5 Latest Latest

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

Go to latest
Published: Oct 30, 2020 License: MIT Imports: 11 Imported by: 0


GoDoc Go Report Card pipeline status coverage report


maze is a package for working with mazes. Some utilities provided are: maze generation, solving, and marshaling/unmarshaling.



Package maze provides generating, solving, and other utilities for working with mazes.



This section is empty.


View Source
var Dijkstra = FinderFn(dijkstra)

Dijkstra is a path finder implementing Dijkstra's algorithm.


func Gray

func Gray(m *Maze) *image.Gray

Gray returns a grayscale image of the maze.


type Finder

type Finder interface {
	// Path returns the ids of the cells from start to end.
	Path(m *Maze, start, end int64) []int64

Finder is anything that can find a path between two cells in a maze

func AStar

func AStar(h func(x, y int64) float64) Finder

AStar is a path finder implementing the A* algorithm.

type FinderFn

type FinderFn func(m *Maze, start, end int64) []int64

FinderFn is a function which implements the Finder interface.

func (FinderFn) Path

func (f FinderFn) Path(m *Maze, start, end int64) []int64

Path implements the Finder interface.

type Generator

type Generator interface {
	// Generate generates a maze.
	Generate(width, height int) *Maze

Generator represents anything that can generate a maze.

func WithKruskal

func WithKruskal(src rand.Source) Generator

WithKruskal2 returns a generator which uses Kruskal's algorithm to generate mazes.

func WithPrim

func WithPrim(src rand.Source) Generator

WithPrim returns a generator which uses Prim's algorithm to generate mazes.

type Maze

type Maze struct {
	// Graph is the underlying structure of the maze.
	// IMPORTANT! This field will be deprecated and removed in the future.
	// It is currently only exported to keep the cli tool happy.
	Graph graph.Weighted
	// contains filtered or unexported fields

Maze 2D rectangular maze.

func FromGray

func FromGray(gray *image.Gray) *Maze

FromGray extracts a maze from a grayscale image.

func Generate added in v0.0.3

func Generate(width, height int, seed int64) *Maze

Generate is a no configuration necessary maze generating function.

func (*Maze) Connected added in v0.0.4

func (m *Maze) Connected(c1, c2 int) bool

Connected returns whether or not two cells in the maze are directly connected.

func (*Maze) Dims added in v0.0.4

func (m *Maze) Dims() (width, height int)

Dims returns the width and height of the maze.

func (*Maze) MarshalDOT

func (m *Maze) MarshalDOT() ([]byte, error)

MarshalDOT marshals the maze as a graph into the DOT language.

func (*Maze) MarshalText

func (m *Maze) MarshalText() ([]byte, error)

MarshalText marshals the maze into a textual form.

func (*Maze) Neighbors added in v0.0.4

func (m *Maze) Neighbors(id int) []int

Neighbors returns all the direct neighbors of a cell.

func (*Maze) UnmarshalText

func (m *Maze) UnmarshalText(text []byte) error

UnmarshalText unmarshals the maze from its textual form.

Jump to

Keyboard shortcuts

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