astar

package
v0.0.0-...-5d524ee Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoPath = goErrs.New("no path found")

Functions

func Search[S State, TileType TileWithCost](
	m *Map[TileType],
	start S, isGoal func(S) bool,
	neighbours func(S) []S,
	h func(from S) int,
	pathHeadFlag TileType, pathTailFlag TileType,
) (cost int, path []Pos, err error)

Search performs an A* search on the given map from the start position to the goal position.

h is the heuristic function that returns the estimated cost from the given position to the goal. func Search[TileType TileWithCost](m *Map[TileType], start Pos, goal Pos, h func(from Pos) int, recordFrames bool, pathHeadFlag TileType, pathTailFlag TileType) (cost int, path []Pos, err error) {

Types

type DirectionalPos

type DirectionalPos struct {
	Pos
	Direction vec2.Vec2
}

type Node

type Node[S State] struct {
	State S

	Parent *Node[S] // The cheapest Parent Node (nil if this is the start Node)
	// contains filtered or unexported fields
}

Node represents a Node in the A* search

func (*Node[S]) Less

func (n *Node[S]) Less(a *Node[S]) bool

type State

type State interface {
	comparable
	Pos() maps.Pos
}

type TileWithCost

type TileWithCost interface {
	Tile

	// Cost returns the cost to move onto this tile on the map
	Cost() int
}

Jump to

Keyboard shortcuts

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