20 corridor = &emptyCorridor;
30 return getBestPath(aMap, from, to, to, rp);
39 Heap *nodeHeap =
new Heap(corridor->size());
40 std::vector<node *> expandedNodes(100);
42 bool exactGoal =
true;
49 int corridorLayer = absLayer;
50 if (corridor->size() > 0)
55 for (
unsigned int x = 0; x < corridor->size(); x++)
56 ((*corridor)[x])->
key = x;
65 expandedNodes.push_back(n);
66 n->
key = expandedNodes.size()-1;
77 if (
verbose) printf(
"considering neighbor %d\n", currNode->GetNum());
78 if (nodeHeap->
IsIn(currNode))
81 relaxEdge(nodeHeap, absGraph, aMap,
85 else if (rp && (absLayer==0) && (currNode != to) && rp->
nodeOccupied(currNode))
87 if (
verbose) printf(
"Can't path to %d, %d (occupied)\n", (
unsigned int)currNode->GetLabelL(
kFirstData), (
unsigned int)currNode->GetLabelL(
kFirstData+1));
88 expandedNodes.push_back(currNode);
89 currNode->key = expandedNodes.size()-1;
93 else if ((currNode->key >= expandedNodes.size()) ||
94 (expandedNodes[currNode->key] != currNode))
97 unsigned int parentKey = par->
key;
101 if ((corridor->size() == 0) ||
102 ((parentKey < corridor->size()) && ((*corridor)[parentKey] == par)))
106 currNode->markEdge(0);
107 nodeHeap->
Add(currNode);
108 if (
verbose) printf(
"Adding neighbor %d\n", currNode->GetNum());
110 relaxEdge(nodeHeap, absGraph, aMap,
114 else {
if (
verbose) printf(
"%d not eligible\n", currNode->GetNum()); }
116 else {
if (
verbose) printf(
"%d already expanded\n", currNode->GetNum()); }
122 if (
verbose) printf(
"Error: We expanded every possible node!\n");
131 if (n == to) {
break; }
136 if ((n != to) && (exactGoal))
139 printf(
"Corridor A* ran and didn't find goal in corridor!\n");
142 corridor = &emptyCorridor;
144 return extractBestPath(absGraph, n->
GetNum());
154 Heap *nodeHeap =
new Heap(corridor->size());
155 std::vector<node *> expandedNodes(100);
157 bool exactGoal =
true;
164 int corridorLayer = absLayer;
165 if (corridor->size() > 0)
170 for (
unsigned int x = 0; x < corridor->size(); x++)
171 ((*corridor)[x])->
key = x;
181 expandedNodes.push_back(n);
182 n->
key = expandedNodes.size()-1;
193 if (
verbose) printf(
"considering neighbor %d\n", currNode->GetNum());
194 if (nodeHeap->
IsIn(currNode))
198 relaxFirstEdge(nodeHeap, absGraph, aMap,
200 from, n, currNode, ato);
202 relaxFinalEdge(nodeHeap, absGraph, aMap,
206 relaxEdge(nodeHeap, absGraph, aMap,
210 else if (rp && (absLayer==0) && (currNode != ato) && rp->
nodeOccupied(currNode))
212 if (
verbose) printf(
"Can't path to %d, %d (occupied)\n", (
unsigned int)currNode->GetLabelL(
kFirstData), (
unsigned int)currNode->GetLabelL(
kFirstData+1));
213 expandedNodes.push_back(currNode);
214 currNode->key = expandedNodes.size()-1;
218 else if ((currNode->key >= expandedNodes.size()) ||
219 (expandedNodes[currNode->key] != currNode))
222 unsigned int parentKey = par->
key;
226 if ((corridor->size() == 0) ||
227 ((parentKey < corridor->size()) && ((*corridor)[parentKey] == par)))
231 currNode->markEdge(0);
232 nodeHeap->
Add(currNode);
233 if (
verbose) printf(
"Adding neighbor %d\n", currNode->GetNum());
237 relaxFirstEdge(nodeHeap, absGraph, aMap,
239 from, n, currNode, ato);
241 relaxFinalEdge(nodeHeap, absGraph, aMap,
245 relaxEdge(nodeHeap, absGraph, aMap,
252 else {
if (
verbose) printf(
"%d not eligible\n", currNode->GetNum()); }
254 else {
if (
verbose) printf(
"%d already expanded\n", currNode->GetNum()); }
260 if (
verbose) printf(
"Error: We expanded every possible node!\n");
269 if (n == ato) {
break; }
274 if ((n != ato) && (exactGoal))
277 printf(
"Corridor A* ran and didn't find goal in corridor!\n");
280 corridor = &emptyCorridor;
282 return extractBestPath(absGraph, n->
GetNum());
345 if (
verbose) printf(
"%d <- ", current);
352 current = e->
getTo();
357 if (
verbose) printf(
"%d\n", current);