Interface INode
The A* algorithm takes a starting node and a goal node and searches from the start to the goal.
The nodes can be setup in a graph ahead of running the algorithm or the children nodes can be generated on the fly when the A* algorithm requests the Children property.
See the square puzzle implementation to see the children being generated on the fly instead of the classical image/graph search with walls.
Namespace: Fibula.Common.Utilities.Pathfinding
Assembly: Fibula.Common.Utilities.dll
Syntax
public interface INode
Properties
| Improve this Doc View SourceEstimatedCost
Gets the estimated cost for this node. This is the heuristic from this node to the goal node, or h.
Declaration
int EstimatedCost { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
HasBeenVisited
Gets or sets a value indicating whether this node is part of the closed list.
Declaration
bool HasBeenVisited { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
MovementCost
Gets the movement cost for this node. This is the movement cost from this node to the starting node, or g.
Declaration
int MovementCost { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
Parent
Gets or sets the parent node to this node.
Declaration
INode Parent { get; set; }
Property Value
| Type | Description |
|---|---|
| INode |
ShouldBeVisited
Gets or sets a value indicating whether this node is part of the open list.
Declaration
bool ShouldBeVisited { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
TotalCost
Gets the total cost for this node. This is the sum of the cost from this node to the starting node, or g, plus the heuristic cost from this node to the goal node, or h. [t = g + h].
Declaration
int TotalCost { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
Methods
| Improve this Doc View SourceFindAdjacent(INodeFactory)
Gets this node's adjacent nodes.
Declaration
IEnumerable<INode> FindAdjacent(INodeFactory nodeFactory)
Parameters
| Type | Name | Description |
|---|---|---|
| INodeFactory | nodeFactory | A reference to the factory to create new nodes. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<INode> | The collection of adjacent nodes. |
IsGoal(INode)
Returns true if this node is the goal, false if it is not the goal.
Declaration
bool IsGoal(INode goal)
Parameters
| Type | Name | Description |
|---|---|---|
| INode | goal | The goal node to compare this node against. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if this node is the goal, false if it s not the goal. |
SetEstimatedCost(INode)
Sets the estimated cost for the current node, or h.
Declaration
void SetEstimatedCost(INode goal)
Parameters
| Type | Name | Description |
|---|---|---|
| INode | goal | Goal node, for acces to the goals position. |
SetMovementCost(INode)
Sets the movement cost for the current node, or g.
Declaration
void SetMovementCost(INode parent)
Parameters
| Type | Name | Description |
|---|---|---|
| INode | parent | Parent node, for access to the parents movement cost. |