Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Container ¶
type Container[T any] struct { Value T // contains filtered or unexported fields }
Container represents the intermediate object stored in the tile map. This container type implements astar.Pather with the following assumptions:
* Neighbors on the cardinal direction are reachable if they exist in the tile map * The cost to traverse any neighbor is always 1 * The cost estimate between any two points in the map is the manhattan distance between them
To override these, override Map.NeighborFunc, Map.CostFunc, and Map.EstimateFunc
func (Container[T]) PathEstimatedCost ¶
func (Container[T]) PathNeighborCost ¶
func (Container[T]) PathNeighbors ¶
func (t Container[T]) PathNeighbors() (results []astar.Pather)
type Map ¶
type Map[T any] struct { NeighborFunc func(container Container[T]) []Container[T] CostFunc func(a, b Container[T]) float64 EstimateFunc func(a, b Container[T]) float64 // contains filtered or unexported fields }
Map represents a fixed size grid of tiles. The top-left tile is [0,0], the bottom-right tile is [w, h]. Tiles are stored internally in a Container which implements astar.Pather with the following assumptions:
* Neighbors on the cardinal direction are reachable if they exist in the tile map * The cost to traverse any neighbor is always 1 * The cost estimate between any two points in the map is the manhattan distance between them
To override these, override Map.NeighborFunc, Map.CostFunc, and Map.EstimateFunc
func FromInput ¶
FromInput creates a Map of runes from the input where each line is one row in the map and each rune in each line is a column.
func FromInputOf ¶
FromInputOf creates a Map of the specified type from the input where each line is one row in the map and each rune in each line is a column whose value is computed using the provided conversion function.
func (*Map[T]) ContainerAt ¶
ContainerAt returns the tile container at the specified coordinates in the tile map
func (*Map[T]) PathBetween ¶
PathBetween uses the A-Star path finding algorithm to find the most efficient path between the two locations in the map. By default, the following constraints are used for finding the path:
* Neighbors on the cardinal direction are reachable if they exist in the tile map * The cost to traverse any neighbor is always 1 * The cost estimate between any two points in the map is the manhattan distance between them
To override these, override Map.NeighborFunc, Map.CostFunc, and Map.EstimateFunc