23 sprintf(name,
"GenericAStar[]");
29 std::vector<uint32_t> &thePath)
32 if (!InitializeSearch(_env, from, to, thePath))
34 while (!DoSingleSearchStep(thePath)) {}
38 std::vector<uint32_t> &thePath)
41 assert(openQueue.size() == 0);
42 assert(closedList.size() == 0);
43 nodesTouched = nodesExpanded = 0;
53 SearchNode first(env->heuristic(goal, start), 0, start, start);
63 if (openQueue.size() == 0)
70 currentOpenNode = GetNextNode();
72 if (env->goalTest(currentOpenNode, goal))
74 ExtractPathToStart(currentOpenNode, thePath);
81 if (
verbose) { printf(
"Opening %d\n", currentOpenNode); }
84 printf(
"Oh no! The current open node is NULL\n");
87 env->getNeighbors(currentOpenNode, neighbors);
90 for (
unsigned int x = 0; x < neighbors.size(); x++)
96 if (closedList.find(
neighbor) != closedList.end())
104 UpdateWeight(currentOpenNode,
neighbor);
108 AddToOpenList(currentOpenNode,
neighbor);
116 return openQueue.top().currNode;
125 closedList[next] = it;
133 double edgeWeight = env->gcost(currOpenNode,
neighbor);
137 prev.
fCost = altCost;
140 openQueue.DecreaseKey(prev);
146 double edgeWeight = env->gcost(currOpenNode,
neighbor);
147 SearchNode n(closedList[currOpenNode].gCost+edgeWeight+env->heuristic(
neighbor, goal),
148 closedList[currOpenNode].gCost+edgeWeight,
151 { printf(
"Adding %u to openQueue, old size %u\n",
neighbor, openQueue.size()); }
156 std::vector<uint32_t> &thePath)
159 if (closedList.find(goalNode) != closedList.end())
161 n = closedList[goalNode];
163 else n = openQueue.find(
SearchNode(goalNode));
174 printf(
"%u items in closed list\n", (
unsigned int)closedList.size());
175 printf(
"%u items in open queue\n", (
unsigned int)openQueue.size());
180 return closedList.size()+openQueue.size();
185 return closedList.begin();
190 if (it == closedList.end())
192 uint32_t val = (*it).first;