AStarSearch ClassDelta Engine Documentation
Algorithm for the graph path finding View code on GitHub
Inheritance Hierarchy

System Object
  DeltaEngine.GameLogic.PathFinding GraphSearch
    DeltaEngine.GameLogic.PathFinding AStarSearch

Namespace: DeltaEngine.GameLogic.PathFinding
Assembly: DeltaEngine.GameLogic.PathFinding (in DeltaEngine.GameLogic.PathFinding.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public class AStarSearch : GraphSearch

The AStarSearch type exposes the following members.

Constructors

  NameDescription
Public methodAStarSearch
Initializes a new instance of the AStarSearch class
Top
Methods

  NameDescription
Protected methodGetNextNode (Inherited from GraphSearch.)
Public methodGetPath (Inherited from GraphSearch.)
Protected methodInitialize (Inherited from GraphSearch.)
Public methodSearch (Overrides GraphSearch Search(Graph, Int32, Int32).)
Top
Fields

  NameDescription
Protected fieldcostSoFar (Inherited from GraphSearch.)
Protected fieldgraph (Inherited from GraphSearch.)
Protected fieldnodesToCheck (Inherited from GraphSearch.)
Protected fieldpreviousNode (Inherited from GraphSearch.)
Protected fieldstartNode (Inherited from GraphSearch.)
Protected fieldtargetNode (Inherited from GraphSearch.)
Protected fieldvisitedNodes (Inherited from GraphSearch.)
Top
Remarks

Tests: DeltaEngine.GameLogic.PathFinding.Tests.AStarSearchTests
Examples

3 unit tests call DeltaEngine.GameLogic.PathFinding.AStarSearch
[Test]
public void SearchForPathBetweenNodes()
{
    Assert.IsTrue(aStar.Search(graph, 0, 2));
    Assert.IsTrue(aStar.Search(graph, 1, 5));
    Assert.IsFalse(aStar.Search(graph, 5, 2));
}
[Test]
public void GraphWithNoNodesHasNoPath()
{
    Assert.IsFalse(aStar.Search(new Graph(0), 0, 0));
}
[Test]
public void CheckPathList()
{
    aStar.Search(graph, 0, 2);
    Assert.AreEqual(2, aStar.GetPath().GetListOfCoordinates().Count);
    aStar.Search(graph, 1, 5);
    Assert.AreEqual(3, aStar.GetPath().GetListOfCoordinates().Count);
}
See Also