A* question

Started by
34 comments, last by Symphonic 16 years, 7 months ago
Quote:Original post by Vorpy
Bad news: I found a counterexample.


I drew it the same way as the image above. In this case it is a Delaunay triangulation, and the path found does not go through the nodes of the shortest path. The red arc makes the upper path longer than the lower path when following the triangulation, but taking the upper path and going straight across is the shortest route. Time to try proving bounds on how far from optimal the path can be?

Edit: Actually it looks like I made a mistake and surprisingly in this picture the green and red path is actually shorter than the light blue path. The counterexample still works though, some stuff needs to be nudged around a little.


This bad case happens because your discretisation of the continuous search space is too sparse. In other words, your triangles are too big for the precision you want in finding the minimum path.
Advertisement
It's a counterexample to Symphonic's conjecture that the optimal path in a delaunay triangulation will contain a superset of the nodes in the true optimal path. The path it finds is still pretty good though, within sqrt(2) of the length of the optimal path, at least for this counterexample.

Even if the discretization is denser, if the obstacles do have the shape of those triangles the bad case will still exist, it will just be much more limited in how much error it can produce. There's an idea: adding extra points to the empty space could limit the error in the pathfinding around polygonal obstacles when using a triangulation as the navigation graph.
fresh thoughts:

I read up on navmaps and other fun things like that. Our (deathcarrot's) problem can be described like this:

We have a space with some 1st order explicit geometric obstacles (points and straight lines forming polygons), we want the Geometrical shortest path, and which means that nodes in the search tree MUST be the points of the geometry, and not some secondary things (like the centroids of convex portions of the non-obstacle space).

We can construct a complete graph and cull edges that don't cross obstacles, but in the worst case this means storing O(n^2) edges, and an exponentially larger path space for searches than with triangulations.

There is no constrained triangulation that will add the necessary steiner points to provide an equivalent planar triangulation without exploding the search space. This is actually trivial to show; suppose there are O(n) secondary lines each of which crosses O(n) triangulation lines then for a constrained triangulation to detect these provide these secondary lines, there must be O(n^2) steiner points added to the plane.

Sooooo what do we do?

I think, the best approach is my original idea :P create a simple triangulation, and add some mechanism to the search to detect simpler paths at search time. Strictly speaking you can't escape the complexity of the search you're trying to do, but at least this way, you're not storing alot of data that's redundant anyway.

Steiner Point: a non-data point added to the space by an algorithm, (in this case, added by the constrained triangulation)
Geordi
George D. Filiotis
This might seem a bit out of context, I didn't read the *whole* discussion. But judging from the example map you showed, I'd use simple steering behaviors for outside areas, since they seem pretty sparse (cast ray to target, for the first object it hits, find an intermediate point to go around it), and A* only inside buildings. Since the buildings seem pretty simple I'd just figure out every possible edge and eliminate the ones that intersect with the walls... A bit brute-force, really, but from my experience it would look good and get the job done!
Quote:Original post by Jotaf
This might seem a bit out of context, I didn't read the *whole* discussion. But judging from the example map you showed, I'd use simple steering behaviors for outside areas, since they seem pretty sparse (cast ray to target, for the first object it hits, find an intermediate point to go around it), and A* only inside buildings. Since the buildings seem pretty simple I'd just figure out every possible edge and eliminate the ones that intersect with the walls... A bit brute-force, really, but from my experience it would look good and get the job done!

Yup, that's the approach I'm currently most considering, although there will be much larger indoor areas as well that encompass several cells, so I'll need to think up a proper indoor navigation system as well (navmeshes sound promising for the moment).

As for the triangulation discussion (taking simple collision avoidance out of the equation for the sake of argument) - I'm still not convinced that with the numbers we're talking about here that it's worth sacrificing run-time performance for a decrease in complexity at the node-generation stage.
Memory consumption certainly shouldn't be an issue, each edge would just be 2 pointers (one at each vertex pointing to the other) so 200-300 vertices worth of edges per 3x3 segment still wouldn't be much of a problem, a few hundred K at most.
Also, say we have a worst case of ~100000 edges to check per segment, this is still a one-time calculation, and I can't see that taking a long time given a point-line intersection is fairly quick to check for (no (maybe one?) sqrt, no trig), and there's quite a few optimisations like bounding circle checks that could be done to reduce the number of possibilities.

Thanks for the input everyone =D
Quote:Original post by DeathCarrot
Thanks for the input everyone =D
You're welcome :) I guess this is why I'm not an AI guy [rolleyes]

Geordi
George D. Filiotis

This topic is closed to new replies.

Advertisement