path

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2021 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package path has a pathfinding algorithm that operates on hexcoords.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func To

func To(from hex.Hex, target hex.Hex, pather Pather) (path []hex.Hex)

To finds a near-optimal path to the target hex.

The first element in the path will be the starting hex, and the last will be the target hex.

If there is no path, this will be empty.

This is an offline search algorithm; there is no caching.

Types

type Pather

type Pather interface {
	// Cost indicates the move cost between a hex and one
	// of its neighbors. Higher values are less desirable.
	// Negative costs are treated as impassable.
	Cost(a hex.Hex, direction int) int

	// EstimatedCost returns the estimated cost between
	// two hexes that are not necessarily neighbors.
	// Negative costs are treated as impassable.
	EstimatedCost(a, b hex.Hex) int
}

Pather contains domain knowledge for finding a path.

Jump to

Keyboard shortcuts

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