You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2a7e06f
Browse filesBrowse the repository at this point in the historyBrowse files
static_assert(is_base_of<AStarState<UserState>, UserState>::value, "UserState must be derived from AStarState!");
60
+
#endif
61
+
56
62
public:// data
57
63
58
64
enum
@@ -214,6 +220,7 @@ template <class UserState> class AStarSearch
214
220
// The user is going to use the Goal Node he passed in
215
221
// so copy the parent pointer of n
216
222
m_Goal->parent = n->parent;
223
+
m_Goal->g = n->g;
217
224
218
225
// A special case is that the goal was passed in as the start state
219
226
// so handle that here
@@ -513,6 +520,20 @@ template <class UserState> class AStarSearch
513
520
returnNULL;
514
521
}
515
522
523
+
// Get final cost of solution
524
+
// Returns FLT_MAX if goal is not defined or there is no solution
525
+
floatGetSolutionCost()
526
+
{
527
+
if( m_Goal && m_State == SEARCH_STATE_SUCCEEDED )
528
+
{
529
+
return m_Goal->g;
530
+
}
531
+
else
532
+
{
533
+
returnFLT_MAX;
534
+
}
535
+
}
536
+
516
537
// For educational use and debugging it is useful to be able to view
517
538
// the open and closed list at each step, here are two functions to allow that.
518
539
@@ -717,6 +738,7 @@ template <class UserState> class AStarSearch
717
738
#if !USE_FSA_MEMORY
718
739
delete node;
719
740
#else
741
+
node->~Node();
720
742
m_FixedSizeAllocator.free( node );
721
743
#endif
722
744
}
@@ -762,6 +784,17 @@ template <class UserState> class AStarSearch
762
784
763
785
};
764
786
787
+
template <classT> classAStarState
788
+
{
789
+
public:
790
+
virtual~AStarState() {}
791
+
virtualfloatGoalDistanceEstimate( T &nodeGoal ) = 0; // Heuristic function which computes the estimated cost to the goal node
792
+
virtualboolIsGoal( T &nodeGoal ) = 0; // Returns true if this node is the goal node
793
+
virtualboolGetSuccessors( AStarSearch<T> *astarsearch, T *parent_node ) = 0; // Retrieves all successors to this node and adds them via astarsearch.addSuccessor()
794
+
virtualfloatGetCost( T &successor ) = 0; // Computes the cost of travelling from this node to the successor node
795
+
virtualboolIsSameState( T &rhs ) = 0; // Returns true if this node is the same as the rhs node
0 commit comments