Class AStar2
- Namespace
- MLEM.Pathfinding
- Assembly
- MLEM.dll
A 2-dimensional implementation of AStar<T> that uses Microsoft.Xna.Framework.Point for positions, and the manhattan distance as its heuristic.
public class AStar2 : AStar<Point>
- Inheritance
-
AStar<Point>AStar2
- Inherited Members
Constructors
AStar2(GetCost, bool, float, int, CollectAdditionalNeighbors)
public AStar2(AStar<Point>.GetCost defaultCostFunction, bool includeDiagonals, float defaultCost = 1, int defaultMaxTries = 10000, AStar<Point>.CollectAdditionalNeighbors defaultAdditionalNeighbors = null)
Parameters
defaultCostFunction
AStar<Point>.GetCostincludeDiagonals
booldefaultCost
floatdefaultMaxTries
intdefaultAdditionalNeighbors
AStar<Point>.CollectAdditionalNeighbors
Methods
CollectNeighbors(Point, ISet<Point>)
This method should populate a set of positions that are considered neighbors
to the given position
. For example, this method might return directly adjacent positions, diagonal positions, or faraway positions that can be teleported to.
protected override void CollectNeighbors(Point position, ISet<Point> neighbors)
Parameters
position
PointThe position whose neighbors to return.
neighbors
ISet<Point>The set to populate with neighbors.
GetHeuristicDistance(Point, Point)
This method should implement a heuristic that determines the total distance between the given start
position and the given second position position
.
Note that this is multiplied with the DefaultCost automatically, so no costs need to be considered in this method's return value.
protected override float GetHeuristicDistance(Point start, Point position)
Parameters
start
PointThe start position.
position
PointThe position to get the distance to.
Returns
- float
The total distance between the two positions.