24 #include <utils/search/astar.h>
58 while ( openList.size() > 0 )
73 while ( openList.size() > 0 )
75 best = openList.top();
90 while ( openList.size() > 0 )
92 best = openList.top();
98 openList.push( initialState );
99 return getSolutionSequence( search() );
108 std::vector< AStarState * > children;
111 while ( openList.size() > 0 )
116 if ( openList.size() > 0 )
118 best = openList.top();
125 while ( closedList.find( key ) != closedList.end() );
128 closedList[key] = best;
137 for (
unsigned int i = 0; i < children.size(); i++ )
138 openList.push( children[i] );
149 std::vector< AStarState * > AStar::getSolutionSequence( AStarState * node )
152 AStarState * state = node;
156 closedList.erase(state->key);
157 solution.insert( solution.begin(), state );
158 state = state->father;
162 while ( closedList.size() > 0 )
164 state = closedList.begin()->second;
165 closedList.erase(state->key);
This is the abstract(!) class for an A* State.
virtual std::vector< AStarState * > generateChildren()=0
Generate all successors and put them to this vector.
virtual bool isGoal()=0
Check, wether we reached a goal or not.
virtual long calculateKey()=0
Generates a unique key for this state.
std::vector< AStarState * > solve(AStarState *initialState)
Solves a situation given by the initial state with AStar, and returns a vector of AStarStates that so...