AStarSearch< UserState >::AStarNode Class Reference

Collaboration diagram for AStarSearch< UserState >::AStarNode:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 AStarNode (UserState *state)
 ~AStarNode ()
void createNeighbourNodes ()
bool operator== (AStarNode &rhs) const
bool operator== (const AStarNode &rhs) const
float getTotalCost () const
float getEntryCost () const
float getEstimatedGoalCost () const
float getTraversalCost () const
AStarNodegetNeighbour (int index)
void setEntryCost (float entryCost)
void setEstimatedGoalCost (float cost)
void setSuccessor (AStarNode *parent)

Public Attributes

UserState * mUserState
AStarNodemSuccessor

Private Attributes

float mEntryCost
float mEstimatedGoalCost
AStarNodemNeighbours [8]
unsigned int mID

Static Private Attributes

static int mNumNodes = 0

Detailed Description

template<class UserState>
class AStarSearch< UserState >::AStarNode

Definition at line 54 of file AStarSearch.h.


Constructor & Destructor Documentation

template<class UserState>
AStarSearch< UserState >::AStarNode::AStarNode ( UserState *  state  )  [inline]

Definition at line 81 of file AStarSearch.h.

References AStarSearch< UserState >::AStarNode::mID, AStarSearch< UserState >::AStarNode::mNeighbours, AStarSearch< UserState >::AStarNode::mNumNodes, and AStarSearch< UserState >::AStarNode::mUserState.

Referenced by AStarSearch< UserState >::AStarNode::createNeighbourNodes().

00082                         : mSuccessor ( NULL ), mUserState ( state),
00083                           mEntryCost ( 0.0 ), mEstimatedGoalCost ( 0.0 )
00084                 {
00085                         mID = mNumNodes++;
00086 
00087                         // Create new nodes for each of the neighbours of this one
00088                         for ( int i = 0; i < mUserState->getNumNeighbours(); i++ )
00089                                 mNeighbours[i] = NULL;
00090 
00091                         //cout << "Node Constructed: " << ++nodeCount << endl;\e
00092                 }

template<class UserState>
AStarSearch< UserState >::AStarNode::~AStarNode (  )  [inline]

Definition at line 96 of file AStarSearch.h.

References AStarSearch< UserState >::AStarNode::mNeighbours, and AStarSearch< UserState >::AStarNode::mUserState.

00097                 {
00098                         //cout << "Node released: " << --nodeCount << endl;
00099                         // Our node may not have any neighbours created yet
00100                         if ( mUserState == NULL )
00101                                 return;
00102 
00103 
00104                         for ( int i = 0; i < mUserState->getNumNeighbours(); i++ )
00105                                 delete mNeighbours[i];
00106                 }


Member Function Documentation

template<class UserState>
void AStarSearch< UserState >::AStarNode::createNeighbourNodes (  )  [inline]

Definition at line 110 of file AStarSearch.h.

References AStarSearch< UserState >::AStarNode::AStarNode(), AStarSearch< UserState >::AStarNode::mNeighbours, and AStarSearch< UserState >::AStarNode::mUserState.

Referenced by AStarSearch< UserState >::setStartState().

00111                 {
00112                         for ( int i = 0; i < mUserState->getNumNeighbours(); i++ )
00113                                 mNeighbours[i] = new AStarNode( mUserState->getNeighbour(i) );
00114                 }

template<class UserState>
float AStarSearch< UserState >::AStarNode::getEntryCost (  )  const [inline]

Definition at line 140 of file AStarSearch.h.

References AStarSearch< UserState >::AStarNode::mEntryCost.

Referenced by AStarSearch< UserState >::_findBestOpenNode(), and AStarSearch< UserState >::advanceSearch().

00141                 {
00142                         return mEntryCost;
00143                 }

template<class UserState>
float AStarSearch< UserState >::AStarNode::getEstimatedGoalCost (  )  const [inline]

Definition at line 146 of file AStarSearch.h.

References AStarSearch< UserState >::AStarNode::mEstimatedGoalCost.

Referenced by AStarSearch< UserState >::_findBestOpenNode().

00147                 {
00148                         return mEstimatedGoalCost;
00149                 }

template<class UserState>
AStarNode* AStarSearch< UserState >::AStarNode::getNeighbour ( int  index  )  [inline]

Definition at line 158 of file AStarSearch.h.

References AStarSearch< UserState >::AStarNode::mNeighbours.

Referenced by AStarSearch< UserState >::advanceSearch().

00159                 {
00160                         assert ( index < 8 );
00161 
00162                         return mNeighbours[index];
00163                 }

template<class UserState>
float AStarSearch< UserState >::AStarNode::getTotalCost (  )  const [inline]

Definition at line 134 of file AStarSearch.h.

References AStarSearch< UserState >::AStarNode::mEntryCost, and AStarSearch< UserState >::AStarNode::mEstimatedGoalCost.

Referenced by AStarSearch< UserState >::_findBestOpenNode(), and AStarSearch< UserState >::HeapCompare::operator()().

00135                 {
00136                         return mEntryCost + mEstimatedGoalCost;
00137                 }

template<class UserState>
float AStarSearch< UserState >::AStarNode::getTraversalCost (  )  const [inline]

Definition at line 152 of file AStarSearch.h.

References AStarSearch< UserState >::AStarNode::mUserState.

00153                 {
00154                         return mUserState->getTraversalCost();
00155                 }

template<class UserState>
bool AStarSearch< UserState >::AStarNode::operator== ( const AStarNode rhs  )  const [inline]

Definition at line 125 of file AStarSearch.h.

References AStarSearch< UserState >::AStarNode::mUserState.

00126                 {
00127                         return ( mUserState == rhs.mUserState );
00128                 }

template<class UserState>
bool AStarSearch< UserState >::AStarNode::operator== ( AStarNode rhs  )  const [inline]

Definition at line 118 of file AStarSearch.h.

References AStarSearch< UserState >::AStarNode::mUserState.

00119                 {
00120                         return ( mUserState == rhs.mUserState );
00121                 }

template<class UserState>
void AStarSearch< UserState >::AStarNode::setEntryCost ( float  entryCost  )  [inline]

Definition at line 169 of file AStarSearch.h.

References AStarSearch< UserState >::AStarNode::mEntryCost.

00170                 {
00171                         mEntryCost = entryCost;
00172                 }

template<class UserState>
void AStarSearch< UserState >::AStarNode::setEstimatedGoalCost ( float  cost  )  [inline]

Definition at line 175 of file AStarSearch.h.

References AStarSearch< UserState >::AStarNode::mEstimatedGoalCost.

Referenced by AStarSearch< UserState >::setStartState().

00176                 {
00177                         mEstimatedGoalCost = cost;
00178                 }

template<class UserState>
void AStarSearch< UserState >::AStarNode::setSuccessor ( AStarNode parent  )  [inline]

Definition at line 181 of file AStarSearch.h.

References AStarSearch< UserState >::AStarNode::mSuccessor.

00182                 {
00183                         mSuccessor = parent;
00184                 }


Member Data Documentation

template<class UserState>
float AStarSearch< UserState >::AStarNode::mEntryCost [private]

Definition at line 67 of file AStarSearch.h.

Referenced by AStarSearch< UserState >::AStarNode::getEntryCost(), AStarSearch< UserState >::AStarNode::getTotalCost(), and AStarSearch< UserState >::AStarNode::setEntryCost().

template<class UserState>
float AStarSearch< UserState >::AStarNode::mEstimatedGoalCost [private]

Definition at line 68 of file AStarSearch.h.

Referenced by AStarSearch< UserState >::AStarNode::getEstimatedGoalCost(), AStarSearch< UserState >::AStarNode::getTotalCost(), and AStarSearch< UserState >::AStarNode::setEstimatedGoalCost().

template<class UserState>
unsigned int AStarSearch< UserState >::AStarNode::mID [private]

Definition at line 75 of file AStarSearch.h.

Referenced by AStarSearch< UserState >::AStarNode::AStarNode().

template<class UserState>
AStarNode* AStarSearch< UserState >::AStarNode::mNeighbours[8] [private]

Definition at line 72 of file AStarSearch.h.

Referenced by AStarSearch< UserState >::AStarNode::AStarNode(), AStarSearch< UserState >::AStarNode::createNeighbourNodes(), AStarSearch< UserState >::AStarNode::getNeighbour(), and AStarSearch< UserState >::AStarNode::~AStarNode().

template<class UserState>
int AStarSearch< UserState >::AStarNode::mNumNodes = 0 [static, private]

Definition at line 74 of file AStarSearch.h.

Referenced by AStarSearch< UserState >::AStarNode::AStarNode().

template<class UserState>
AStarNode* AStarSearch< UserState >::AStarNode::mSuccessor

Definition at line 62 of file AStarSearch.h.

Referenced by AStarSearch< UserState >::AStarNode::setSuccessor().

template<class UserState>
UserState* AStarSearch< UserState >::AStarNode::mUserState

Definition at line 59 of file AStarSearch.h.

Referenced by AStarSearch< UserState >::advanceSearch(), AStarSearch< UserState >::AStarNode::AStarNode(), AStarSearch< UserState >::AStarNode::createNeighbourNodes(), AStarSearch< UserState >::AStarNode::getTraversalCost(), AStarSearch< UserState >::AStarNode::operator==(), AStarSearch< UserState >::setStartState(), and AStarSearch< UserState >::AStarNode::~AStarNode().


The documentation for this class was generated from the following file:
Generated on Sun Jun 25 19:23:43 2006 for Valors End by  doxygen 1.4.7