de.rico.engine.path
Class AStarNode

java.lang.Object
  extended by de.rico.engine.path.AStarNode
All Implemented Interfaces:
java.lang.Comparable
Direct Known Subclasses:
GridNode

public abstract class AStarNode
extends java.lang.Object
implements java.lang.Comparable

The AStarNode class, along with the AStarSearch class, implements a generic A* search algorthim. The AStarNode class should be subclassed to provide searching capability.

Author:
David Brackeen (Book: Developing Games in Java), minor additions by Frank Bruns

Constructor Summary
AStarNode()
           
 
Method Summary
 int compareTo(java.lang.Object other)
           
 float getCost()
          Returns the cost of the node
abstract  float getCost(AStarNode node)
          Gets the cost between this node and the specified adjacent (aka "neighbor" or "child") node.
abstract  float getEstimatedCost(AStarNode node)
          Gets the estimated cost between this node and the specified node.
abstract  java.util.List getNeighbors()
          Gets the children (aka "neighbors" or "adjacent nodes") of this node.
 int sign(float v)
          Returns the sign of the number.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AStarNode

public AStarNode()
Method Detail

getCost

public float getCost()
Returns the cost of the node

Returns:
cost of the node

compareTo

public int compareTo(java.lang.Object other)
Specified by:
compareTo in interface java.lang.Comparable

getCost

public abstract float getCost(AStarNode node)
Gets the cost between this node and the specified adjacent (aka "neighbor" or "child") node.


getEstimatedCost

public abstract float getEstimatedCost(AStarNode node)
Gets the estimated cost between this node and the specified node. The estimated cost should never exceed the true cost. The better the estimate, the more effecient the search.


getNeighbors

public abstract java.util.List getNeighbors()
Gets the children (aka "neighbors" or "adjacent nodes") of this node.


sign

public int sign(float v)
Returns the sign of the number. Returns -1 for negative, 1 for positive, and 0 otherwise.