15 :MapAbstraction(_map), lineDistance(dist), abstractUniformly(uniform)
24 bool MapLineAbstraction::MapLineAbstraction::Pathable(
node *from,
node *to)
28 if ((!from) || (!to) ||
37 if ((from == 0) || (to == 0))
77 while (abstractions.back()->GetNumEdges() > 0)
87 abstractions.push_back(g);
97 int count = abstractions.back()->GetNumNodes();
99 int xstep = pow(
lineDistance,((abstractions.size()+1)/2));
100 int ystep = pow(
lineDistance,((abstractions.size())/2));
101 int zstep = pow(
lineDistance,((abstractions.size()-1)/2));
102 Graph *toAbstract = abstractions.back();
107 for (
int x = 0; x < GetMap()->GetMapWidth(); x += xstep)
109 for (
int y = 0; y < GetMap()->GetMapHeight(); y+= ystep)
112 std::vector<node *> nodes;
113 std::vector<node *> parents;
116 if ((abstractions.size()%2) != 0)
119 nodes.push_back(GetNodeFromMap(x+z*zstep, y));
123 nodes.push_back(GetNodeFromMap(x, y+z*zstep));
126 if (nodes.back() == 0)
132 parents.push_back(GetNthParent(nodes.back(), abstractions.size()-1));
133 if ((parents.back() == 0) ||
134 (parents.back()->GetLabelL(
kParent) != -1) ||
135 ((z > 0) && (!toAbstract->
FindEdge(parents[z]->GetNum(), parents[z-1]->GetNum()))))
144 if ((nodes.size() == 0) || (parents.size() == 0))
149 for (
unsigned int z = 0; z < parents.size(); z++)
151 if (parents[z]->GetLabelL(
kParent) != -1)
163 std::vector<node *> stopList;
167 node *n = abstractions.back()->GetRandomNode();
188 if ((random()%100) < 100.0/prob)
209 if ((n->
key < stopList.size()) && (stopList[n->
key] == n))
216 n->
key = stopList.size();
217 stopList.push_back(n);
226 Graph *g = abstractions.back();
234 if ((from == -1) || (to == -1))
236 printf(
"Error, (%d parent %d) or (%d parent %d) didn't get abstracted!\n",
237 e->getFrom(), from, e->getTo(), to);
240 if ((from != to) && (!(f = aGraph->
FindEdge(to, from))))
243 f =
new edge(from, to, weight);
253 assert(GetAbstractionLevel(n)+1 == GetAbstractionLevel(parent));
264 assert(parent!=NULL);