• Articles
  • Api Documentation
Show / Hide Table of Contents
  • AnyPath
    • Graphs
      • Extra
        • Line2D
        • Line3D
        • Triangle
      • HexGrid
        • HexGrid
        • HexGrid.Enumerator
        • HexGridCell
        • HexGridHeuristicProvider
        • HexGridType
      • Line
        • ClosestLineLocationPredicate
        • LineGraph
        • LineGraph.Edge
        • LineGraph.Enumerator
        • LineGraphBuilder
        • LineGraphBuilder.ProtoEdge
        • LineGraphDrawer
        • LineGraphHeuristic
        • LineGraphLocation
        • LineGraphPopulator
        • LineGraphProcessor
        • LineGraphWelder
        • SceneGraph
          • LineGraphNode
          • LineSceneGraph
          • LineSceneGraphEdge
          • SceneGraphNodeEditor
      • NavMesh
        • ClosestNavMeshLocationPredicate
        • CornerAndNormal
        • IUnrolledNavMeshGraphPortal
        • NavMeshGraph
        • NavMeshGraph.EnterCostAndFlags
        • NavMeshGraph.Enumerator
        • NavMeshGraphCorners
        • NavMeshGraphCorners3D
        • NavMeshGraphHeuristic
        • NavMeshGraphLocation
        • NavMeshGraphUnroller
        • NavMeshLineBitmaskMod
        • NavMeshLineMod
        • NavMeshPlaneBitmaskMod
        • NavMeshPlaneMod
        • NavMeshPopulator
        • NavMeshWelder
        • SSFA
        • UnrolledNavMeshGraphPortal
      • Node
        • NodeGraph
        • NodeGraphNode
      • PlatformerGraph
        • ClosestPlatformerGraphLocationPredicate
        • PlatformerGraph
        • PlatformerGraph.Enumerator
        • PlatformerGraphBuilder
        • PlatformerGraphBuilder.ProtoEdge
        • PlatformerGraphDrawer
        • PlatformerGraphHeuristic
        • PlatformerGraphLocation
        • PlatformerGraphPopulator
        • PlatformerGraphProcessor
        • PlatformerGraphWelder
        • SceneGraph
          • PlatformerSceneGraph
          • PlatformerSceneGraphEdge
          • PlatformerSceneGraphNode
          • SceneGraphNodeEditor
      • SquareGrid
        • SquareGrid
        • SquareGrid.Enumerator
        • SquareGridCell
        • SquareGridHeuristicProvider
        • SquareGridHeuristicProviderEightDirectional
        • SquareGridHeuristicProviderManhattanDistance
        • SquareGridType
      • VoxelGrid
        • VoxelGrid
        • VoxelGrid.DirCost
        • VoxelGrid.Enumerator
        • VoxelGridCell
        • VoxelGridDirectionFlags
        • VoxelGridDirectionMod
        • VoxelGridHeuristicProvider
        • VoxelGridHeuristicProviderManhattanDistance
    • Managed
      • ClearFinderFlags
      • FinderExtensions
      • IFinder
      • IOptionReserver<TOption>
      • IOptionValidator<TOption>
      • ImmutableFinderException
      • ManagedDisposeExtensions
      • Results
        • DijkstraResult<TNode>
        • Eval
        • Eval<TOption>
        • MultiEvalResult
        • MultiPathResult<TSeg>
        • Path<TSeg>
        • Path<TOption, TSeg>
    • Native
      • AStarCheapestOption
      • AStarEvalOptionResult
      • AStarEvalResult
      • AStarFindOptionResult
      • AStarFindPathResult
      • AStarOption
      • AStarStops
      • AStar<TNode>
      • ComposedGraph<TGraph, TNode>
      • Edge<TNode>
      • FlagBitmask<TNode>
      • IEdgeMod<TNode>
      • IGraph<TNode>
      • IHeuristicProvider<TNode>
      • INodeFlags
      • IPathProcessor<TNode, TSeg>
      • NativeListWrapper<TSeg>
      • NoEdgeMod<TNode>
      • NoProcessing<TNode>
      • OffsetInfo
      • ReversedGraph<TNode>
      • EdgeMods
        • AdditionalAndExcludeEdges<TNode>
        • AdditionalEdges<TNode>
        • ExcludeEdges<TNode>
        • ExcludeLocations<TNode>
      • Heuristics
        • ALTCompute<TGraph, TNode>
        • ALTSerialization
        • ALT<TNode>
        • LandmarkSelection<TGraph, TNode, TEnumerator>
      • Util
        • IRefComparer<T>
        • NativeMinHeap<T, TComp>
        • NativeRefMinHeap<T, TComp>

Struct ALT<TNode>

ALT heuristic provider that works on any type of graph. This can significantly speed up A* queries on large and complex graphs. Based on this research: https://www.microsoft.com/en-us/research/publication/computing-the-shortest-path-a-search-meets-graph-theory/?from=http%3A%2F%2Fresearch.microsoft.com%2Fpubs%2F154937%2Fsoda05.pdf

To generate ALT heuristics, you must use ALTCompute<TGraph, TNode> and optionally LandmarkSelection<TGraph, TNode, TEnumerator>. The included Square grid example demonstrates this process.

Implements
IHeuristicProvider<TNode>
IDisposable
Namespace: AnyPath.Native.Heuristics
Assembly: AnyPath.dll
Syntax
public struct ALT<TNode> : IHeuristicProvider<TNode>, IDisposable where TNode : unmanaged, IEquatable<TNode>
Type Parameters
Name Description
TNode
Remarks

For best results, landmarks should be placed "behind" frequent start and goal locations.

Constructors

ALT(Allocator)

Allocates an ALT heuristic provider.

Declaration
public ALT(Allocator allocator)
Parameters
Type Name Description
Allocator allocator

Allocator for the ALT heuristics.

Properties

IsDirected

Returns wether this ALT heuristic provider was made for a directed graph.

Declaration
public bool IsDirected { get; }
Property Value
Type Description
bool

LandmarkCount

Returns the amount of landmarks in this provider.

Declaration
public int LandmarkCount { get; }
Property Value
Type Description
int

Methods

GetFromKeyValueArrays(Allocator)

Returns key value arrays containing the graph distances from every landmark. This can be useful if you want to serialize the data. If you know your graph is undirected, it is sufficient to only serialize this data.

Declaration
public NativeKeyValueArrays<TNode, FixedList128Bytes<float>> GetFromKeyValueArrays(Allocator allocator)
Parameters
Type Name Description
Allocator allocator

Allocator to use for the key value array

Returns
Type Description
NativeKeyValueArrays<TNode, FixedList128Bytes<float>>

GetLandmarkLocation(int)

Returns the location of the landmark at a given index.

Declaration
public TNode GetLandmarkLocation(int index)
Parameters
Type Name Description
int index

The index

Returns
Type Description
TNode

The landmark location

GetNativeContainers(out NativeHashMap<TNode, FixedList128Bytes<float>>, out NativeHashMap<TNode, FixedList128Bytes<float>>, out NativeList<TNode>, out NativeReference<bool>)

Returns the internal native containers which can be used to serialize the data.

Declaration
public void GetNativeContainers(out NativeHashMap<TNode, FixedList128Bytes<float>> fromLandmarks, out NativeHashMap<TNode, FixedList128Bytes<float>> toLandmarks, out NativeList<TNode> landmarks, out NativeReference<bool> isDirected)
Parameters
Type Name Description
NativeHashMap<TNode, FixedList128Bytes<float>> fromLandmarks
NativeHashMap<TNode, FixedList128Bytes<float>> toLandmarks
NativeList<TNode> landmarks
NativeReference<bool> isDirected

GetToKeyValueArrays(Allocator)

Returns key value arrays containing the graph distances to every landmark. This can be useful if you want to serialize the data. For undirected graphs, this data will be the same as GetFromKeyValueArrays(Allocator) so doesn't need to be serialized.

Declaration
public NativeKeyValueArrays<TNode, FixedList128Bytes<float>> GetToKeyValueArrays(Allocator allocator)
Parameters
Type Name Description
Allocator allocator

Allocator to use for the key value array

Returns
Type Description
NativeKeyValueArrays<TNode, FixedList128Bytes<float>>

Heuristic(TNode)

Returns a cost estimate of a path between two nodes. Depending on the location of the landmarks, this estimate can be significantly better than a traditional heuristic, resulting in much less expanded nodes and thus faster pathfinding.

Declaration
public float Heuristic(TNode u)
Parameters
Type Name Description
TNode u
Returns
Type Description
float
Remarks

In order for the algorithm to work correctly, the edge cost's may not be negative.

SetGoal(TNode)

Gets called by A* before the algorithm begins, keep track of the goal internally.

Declaration
public void SetGoal(TNode goal)
Parameters
Type Name Description
TNode goal

Implements

IHeuristicProvider<TNode>
IDisposable

Extension Methods

FinderExtensions.AddOption<T, TNode, TOption>(T, TOption, TNode, TNode)
FinderExtensions.AddOptions<T, TNode, TOption>(T, IEnumerable<TOption>, TNode, Func<TOption, TNode>)
FinderExtensions.AddRange<T, TNode, TOption>(T, IEnumerable<TOption>, TNode, Func<TOption, TNode>)
FinderExtensions.AddRequest<T, TNode>(T, TNode, TNode)
FinderExtensions.AddRequests<T, TNode>(T, IEnumerable<TNode>)
FinderExtensions.AddStop<T, TNode>(T, TNode)
FinderExtensions.AddStops<T, TNode>(T, IEnumerable<TNode>)
FinderExtensions.SetComparer<T, TOption>(T, IComparer<TOption>)
FinderExtensions.SetEdgeMod<T, TMod>(T, TMod)
FinderExtensions.SetGraph<T, TGraph>(T, TGraph)
FinderExtensions.SetHeuristicProvider<T, TH>(T, TH)
FinderExtensions.SetPathProcessor<T, TProc>(T, TProc)
FinderExtensions.SetReserver<T, TOption>(T, IOptionReserver<TOption>)
FinderExtensions.SetStartAndGoal<T, TNode>(T, TNode, TNode)
FinderExtensions.SetValidator<T, TOption>(T, IOptionValidator<TOption>)
ALTSerialization.ReadFrom<TNode>(ALT<TNode>, BinaryReader, Func<BinaryReader, TNode>)
ALTSerialization.WriteTo<TNode>(ALT<TNode>, BinaryWriter, Action<BinaryWriter, TNode>)
In This Article
Back to top Generated by DocFX