Class AStar
The core A* implementation used by AnyPath.
All parameters are ordered as: Graph - Input - Working Memory - Output All type parameters are ordered as: Graph / Input - Working Memory Types - Output (Processing/Segments)
Inheritance
Namespace: AnyPath.Native
Assembly: Assembly-CSharp.dll
Syntax
public static class AStar
Remarks
All of the methods contained in the AnyPath.Native namespace are compatible with Unity's Burst compiler
Some of these methods contain a lot of parameters. Unfortunately, C# type inference does not work sufficiently on extension methods of interfaces. It can only infer types based on method arguments. So a struct implementing some IFindPathArgs the arguments as properties does not work without still specifying all of the type arguments for the extension method.
Methods
| Improve this Doc View SourceDijkstra<TGraph, TNode>(ref TGraph, TNode, ref Memory<TNode>)
Performs the Dijkstra algorithm on the graph. The result of which can be obtained via the memory.cameFrom set. Which will contain all of the shortest paths from start to every reachable node in the graph.
Declaration
public static void Dijkstra<TGraph, TNode>(this ref TGraph graph, TNode start, ref Memory<TNode> memory)
where TGraph : struct, IGraph<TNode> where TNode : struct, IEquatable<TNode>
Parameters
Type | Name | Description |
---|---|---|
TGraph | graph | |
TNode | start | |
Memory<TNode> | memory |
Type Parameters
Name | Description |
---|---|
TGraph | |
TNode |
Remarks
Warning Running this algorithm on a graph without a boundary will result in an infinite loop
EvalPath<TGraph, TNode, TH, TMod>(ref TGraph, TNode, TNode, ref Memory<TNode>, ref TH, ref TMod, Boolean)
Evaluates if a path exists between two nodes in the graph.
Declaration
public static AStarEvalResult EvalPath<TGraph, TNode, TH, TMod>(this ref TGraph graph, TNode start, TNode goal, ref Memory<TNode> memory, ref TH heuristicProvider, ref TMod edgeMod, bool initMemory = true)
where TGraph : struct, IGraph<TNode> where TNode : struct, IEquatable<TNode> where TH : struct, IHeuristicProvider<TNode> where TMod : struct, IEdgeMod<TNode>
Parameters
Type | Name | Description |
---|---|---|
TGraph | graph | The graph to perform the request on |
TNode | start | The starting node |
TNode | goal | The goal node |
Memory<TNode> | memory | Working memory for the algorithm to use |
TH | heuristicProvider | |
TMod | edgeMod | |
System.Boolean | initMemory |
Returns
Type | Description |
---|---|
AStarEvalResult | A AStarEvalResult struct containing the result |
Type Parameters
Name | Description |
---|---|
TGraph | The type of graph to find a path on |
TNode | Type of nodes |
TH | |
TMod |
Remarks
This method does not reconstruct the path. See
FindPath<TGraph, TNode, TH, TMod, TProc, TSeg>(ref TGraph, TNode, TNode, ref Memory<TNode>, ref TH, ref TMod, ref TProc, ref NativeList<TSeg>)
Evaluates and then reconstructs a path from start to goal.
Declaration
public static AStarFindPathResult FindPath<TGraph, TNode, TH, TMod, TProc, TSeg>(this ref TGraph graph, TNode start, TNode goal, ref Memory<TNode> memory, ref TH heuristicProvider, ref TMod edgeMod, ref TProc pathProcessor, ref NativeList<TSeg> pathBuffer)
where TGraph : struct, IGraph<TNode> where TNode : struct, IEquatable<TNode> where TH : struct, IHeuristicProvider<TNode> where TMod : struct, IEdgeMod<TNode> where TProc : struct, IPathProcessor<TNode, TSeg> where TSeg : struct
Parameters
Type | Name | Description |
---|---|---|
TGraph | graph | The graph to perform the request on |
TNode | start | The starting location |
TNode | goal | The goal location |
Memory<TNode> | memory | Working memory for the algorithm to use |
TH | heuristicProvider | |
TMod | edgeMod | |
TProc | pathProcessor | |
Unity.Collections.NativeList<TSeg> | pathBuffer | The segment buffer to append the path to. This buffer is not cleared. |
Returns
Type | Description |
---|---|
AStarFindPathResult | A AStarFindPathResult struct indicating if a path was found and the offsets in the path buffer |
Type Parameters
Name | Description |
---|---|
TGraph | The type of graph to find a path on |
TNode | Type of nodes |
TH | |
TMod | |
TProc | Type of the path processor |
TSeg | Type of segments make up the path |