pathfinding

package
v0.0.0-...-fcffdc5 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2020 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cost

type Cost uint32
const (
	HorizontalCost Cost = 2
	VerticalCost   Cost = 2
	DiagonalCost   Cost = 3
)

we cannot have diagonal costs be the same as the others, because then the path will zig-zag

type Link struct {
	Point
	Cost
}

type Point

type Point struct {
	X, Y uint
}
func Search(start Point, goal Point, canTraverse func(Point) bool) []Point

implemented from https://en.wikipedia.org/wiki/A*_search_algorithm

func (Point) Adjacent

func (p Point) Adjacent(exists func(Point) bool) (px []Link)

func (Point) Heuristic

func (p Point) Heuristic(goal Point) Cost

compute the largest of the horizontal and vertical distance, because diagonals.

type PointEntry

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

type SearchState

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

based on example from https://golang.org/pkg/container/heap/

func NewSearchState

func NewSearchState() *SearchState

func (*SearchState) GetEntry

func (ss *SearchState) GetEntry(p Point) *PointEntry

func (*SearchState) Len

func (ss *SearchState) Len() int

func (*SearchState) Less

func (ss *SearchState) Less(i, j int) bool

func (*SearchState) Pop

func (ss *SearchState) Pop() interface{}

func (*SearchState) Push

func (ss *SearchState) Push(x interface{})

func (*SearchState) Swap

func (ss *SearchState) Swap(i, j int)

Jump to

Keyboard shortcuts

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