Skip to main content

AStar<TNode, TConnection>

A static class in Root.Township, the global namespace.

Generic A* path search over any node and connection types that implement the A* interfaces. Search state is stored on each node's WorkingNode, so don't run two searches over the same nodes at once.

Methods​

MemberWhat it is
static bool IsWithinNodes(TNode start, TNode end, int count, AStarTravelCondition<TNode, TConnection> travelCondition = null)True if the end can be reached from the start within the given number of steps.
static bool Pathfind(TNode start, AStarDestinationCondition<TNode, TConnection> condition, out List<TConnection> path, out TNode end, out float distance, AStarTravelCondition<TNode, TConnection> travelCondition = null, bool isTracingBack = true, int maxNodeCount = -1)Finds the cheapest path to a target node, a set of possible ends (with heuristic), or any node passing a condition (no heuristic). Skips disabled connections.
static bool Pathfind(TNode start, ICollection<TNode> possibleEnd, out List<TConnection> path, out TNode end, out float distance, AStarTravelCondition<TNode, TConnection> travelCondition = null, bool isTracingBack = true, int maxNodeCount = -1)Finds the cheapest path to a target node, a set of possible ends (with heuristic), or any node passing a condition (no heuristic). Skips disabled connections.
static List<TConnection> Pathfind(TNode start, TNode end, AStarTravelCondition<TNode, TConnection> travelCondition = null)Finds the cheapest path to a target node, a set of possible ends (with heuristic), or any node passing a condition (no heuristic). Skips disabled connections.
1 private and internal method
MemberWhat it is
private static List<TConnection> TraceBack(bool isTracingBack, Dictionary<TNode, TConnection> from, TNode current, out float distance)Walks back from the end to build the connection list and total cost, or just the cost.