astar

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2025 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Goreland

type Goreland struct {
}

Goreland astar implementation

func (Goreland) RenderPath

func (w Goreland) RenderPath(path []Pather) string

RenderPath renders a path on top of a Goreland world.

type Pather

type Pather interface {
	// PathNeighbors returns the direct neighboring nodes of this node which
	// can be pathed to.
	PathNeighbors() []Pather
	// PathNeighborCost calculates the exact movement cost to neighbor nodes.
	PathNeighborCost(to Pather) float64
	// PathEstimatedCost is a heuristic method for estimating movement costs
	// between non-adjacent nodes.
	PathEstimatedCost(to Pather) float64
}

Pather is an interface which allows A* searching on arbitrary objects which can represent a weighted graph.

func Path

func Path(from, to Pather) (path []Pather, distance float64, found bool)

Path calculates a short path and the distance between the two Pather nodes.

If no path is found, found will be false.

type Truck

type Truck struct {
	// X and Y are the coordinates of the truck.
	X, Y int
	// contains filtered or unexported fields
}

A Truck is a Truck in a grid which implements Grapher.

func (*Truck) PathEstimatedCost

func (t *Truck) PathEstimatedCost(to Pather) float64

PathEstimatedCost uses Manhattan distance to estimate orthogonal distance between non-adjacent nodes.

func (*Truck) PathNeighborCost

func (t *Truck) PathNeighborCost(to Pather) float64

PathNeighborCost returns the cost of the tube leading to Truck.

func (*Truck) PathNeighbors

func (t *Truck) PathNeighbors() []Pather

PathNeighbors returns the neighbors of the Truck

type Tube

type Tube struct {
	Cost float64
	// contains filtered or unexported fields
}

Tube contains from and to Truck with cost

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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