maze

package
v0.0.0-...-7d7b408 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SymbolWall  = '#'
	SymbolEmpty = '.'
)

Variables

This section is empty.

Functions

func CoordToId

func CoordToId[T comparable](m *matrix.Matrix[T], c matrix.Coord) int64

CoordToId translates coordinates inside the matrix to a unique id.

func IdToCoord

func IdToCoord[T comparable](m *matrix.Matrix[T], id int64) matrix.Coord

IdToCoord translates an previously generated id back to coordinates inside the matrix.

Types

type PathFinder

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

PathFinder helps find paths within a Matrix[byte].

func NewSimplePathFinder

func NewSimplePathFinder(m *matrix.Matrix[byte]) *PathFinder

NewSimplePathFinder creates a PathFinder

func (*PathFinder) AddSpecialNode

func (pf *PathFinder) AddSpecialNode(m *matrix.Matrix[byte], c matrix.Coord, invert bool)

AddSpecialNode adds a new node in the graph at coordinate c. It will search all the reachable neightbors from this point and create path FROM it to these. If invert is true, it will create path from all reachable neighbors TO this point.

func (*PathFinder) FindAllDijkstra

func (pf *PathFinder) FindAllDijkstra(from, to matrix.Coord) ([][]matrix.Coord, int64)

FindDijkstra uses the Dijkstra algorithm to find all shortest paths from a coordinate to another.

func (*PathFinder) FindDijkstra

func (pf *PathFinder) FindDijkstra(from, to matrix.Coord) ([]matrix.Coord, int64)

FindDijkstra uses the Dijkstra algorithm to find a shortest path from a coordinate to another.

func (*PathFinder) Graph

Graph returns the underlying graph contained in the PathFinder.

Jump to

Keyboard shortcuts

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