Table of Contents

Method AStar

Namespace
Gamelogic.Grids2
Assembly
Gamelogic.Grids2.dll

AStar<TPoint>(IGrid<TPoint>, TPoint, TPoint, Func<TPoint, TPoint, float>, Func<TPoint, bool>, Func<TPoint, IEnumerable<TPoint>>, Func<TPoint, TPoint, float>)

Find the shortest path between a start and goal node.

public static IEnumerable<TPoint> AStar<TPoint>(IGrid<TPoint> grid, TPoint start, TPoint goal, Func<TPoint, TPoint, float> heuristicCostEstimate, Func<TPoint, bool> isAccessible, Func<TPoint, IEnumerable<TPoint>> getConnectedPoints, Func<TPoint, TPoint, float> neighborToNeighborCost)

Parameters

grid IGrid<TPoint>

Grid in which the operation is performed.

start TPoint

Point where the path must start.

goal TPoint

Point where the path must end.

heuristicCostEstimate Func<TPoint, TPoint, float>

This function is used to calculate the heuristic.

isAccessible Func<TPoint, bool>

This function is used to check if a point is accessible within the grid.

getConnectedPoints Func<TPoint, IEnumerable<TPoint>>

This function is used to get the connected points of a given point.

neighborToNeighborCost Func<TPoint, TPoint, float>

This function is used to calculate the cost of moving to a given neighbor.

Returns

IEnumerable<TPoint>

The list of nodes on the path in order.If no path is possible, null is returned.

Type Parameters

TPoint

Remarks

For detailed documentation on how this method works, see