24 sprintf(name,
"aStar[]");
34 assert(openQueue.size() == 0);
35 assert(closedList.size() == 0);
36 nodesTouched = nodesExpanded = 0;
40 if ((from == 0) || (to == 0) || (from == to) || (!aMap->
Pathable(from, to)))
42 g = abstr->GetAbstractGraph(start);
44 SearchNode first(internalHeuristic(goal, start), 0, 0, start, start);
54 eligibleNodes.resize(0);
55 buildCorridor(corridor,
width);
60 node *currentOpenNode = 0;
61 while ((openQueue.size() > 0) && (currentOpenNode != target))
64 currentOpenNode = getNextNode();
65 if (currentOpenNode == target)
68 if (currentOpenNode == 0)
69 printf(
"Oh no! The current open node is NULL\n");
77 if ((which = e->getFrom()) == currentOpenNode->
GetNum()) which = e->getTo();
81 if (closedList.find(
neighbor) != closedList.end())
88 if (
verbose) { printf(
"skipping occupied node %d\n",
neighbor->GetNum()); }
93 if (
verbose) { printf(
"node %d not in corridor\n",
neighbor->GetNum()); }
99 updateWeight(currentOpenNode,
neighbor, e);
104 addToOpenList(currentOpenNode,
neighbor, e);
109 if (currentOpenNode == target)
112 path *p = extractPathToStart(g, currentOpenNode);
135 closedList[next] = it;
157 prev.
fCost = altCost;
164 openQueue.DecreaseKey(prev);
172 closedList[currOpenNode].gCost+e->
GetWeight(),
176 { printf(
"Adding %u to openQueue, old size %u, ",
neighbor->GetNum(), openQueue.size()); }
181 printf(
"New size %u\n", openQueue.size());
211 printf(
"%u items in closed list\n", (
unsigned int)closedList.size());
213 printf(
"%u items in open queue\n", (
unsigned int)openQueue.size());
218 return closedList.size()+openQueue.size();
225 addNeighborsToCorridor(abstr->GetAbstractGraph(t->n), t->n, windowSize);
233 eligibleNodes[n] =
true;
240 if ((which = e->getFrom()) == n->
GetNum()) which = e->getTo();
244 addNeighborsToCorridor(_g,
neighbor, windowSize-1);
252 return ((eligibleNodes.size() == 0) ||
253 (eligibleNodes.find(abstr->GetParent(n)) != eligibleNodes.end()));
259 return abstr->h(from, to);