Pathfinding Routine & Libraries for Slower Areas

  • Thread starter Hepth
  • Start date
  • Tags
    Libraries
In summary, the conversation discusses various methods for pathfinding and optimizing routes with varying costs. These include A* modified with weights, lightmapping or bitmapping, and using genetic algorithms or heuristics to find the best path. The conversation also mentions the challenges of parallelizing these algorithms and suggests using techniques such as dividing the map into patches or using parallel computing libraries. Ultimately, the conversation highlights the importance of considering different metrics, such as time or cost, when finding the optimal route.
  • #1
Hepth
Gold Member
464
40
I'm looking for the name of a routine for pathfinding or some libraries, where it can have slow areas.

I know what A* is for binary paths, but what about paths that have regions where you might want to avoid, but only to a certain cost. Like, if there is mud that slows you by 1/2, then there are times its more efficient to cross that "mud".

I took an A* and modified it so I could put weights at each point, and it works, but I'm wondering if this has an official name? Maybe a programmer can help me.

I'm doing a hobby project where I need a 2D pathfinding over a 200x200 grid where some squares "cost" more than others, and if it can be parallelized it would be even better. It's going to be used for a Neural Net so I have to think about optimization too.

Thanks!
 
Technology news on Phys.org
  • #2
What about using a genetic algorithm to find the best path?

Each solution would be a potential path that you score and keep if above some threshold value for your next generation. You iterate thru several generations and finally choose the one with the best score.
 
  • #3
Hepth said:
I took an A* and modified it so I could put weights at each point, and it works, but I'm wondering if this has an official name? Maybe a programmer can help me.
Lightmapping, bitmapping...
I've never heard that given a name, but I know it's very common in games. I wrote a series of articles many years ago about using maps for cheap pseudo-intelligence. I always called it light mapping, because originally, that's what I figured out how to do it with, figuring out how to light a character as it moved through space.

You can have your blocks actually have multiple variables and a function that returns their weight.
 
  • #4
Yeah, its sort of like a greyscale bumpmap.
In a mathematical sense its like having a variable density grid, where some squares cost double to cross because they have a more dense spatial grid.
If it was in a video game (which it isnt) it'd be like having a bot cross water or jump a wall to find the minimum time path.

I could see how its lightmapping, its basically like ray tracing with different refraction indices. I'll look into that.

In the end I could just program it myself, as I have done. But I know A* isn't the fastest when there's symmetry, and I thought SURELY someone else has done this really well. Give it a greyscale bitmap and it finds the path of least resistance.

I'd rather not do it in a random way, but a path-finding way that builds from the diagonal out.
 
  • #5
About parallelising, it seems like it should be possible.
You're looking at a very symmetric graph. You assign a weight to each vertex (the cost to traverse the corresponding square).

How to parallelize this? I'd say divide your square map in patches (n x n or n x m doesn't really matter).
In each patch look for the optimal path.

Now comes the hard part, patching these paths together in such a way that you optimize your metric (whatever it is like time, fuel consumption, ...)
This is hard because of several reasons, some sections can be ignored but you'll need to lessen the efficiency almost always.
Snapshot.jpg


I drew a simple sketch here. Suppose each of the smaller grids containing a black path is such a section.
As you can see they don't align.

Suppose the best path possible is the grey one (there's a big swamp at the bottom :) ).
You'll want to go from the upperleft to it's right neighbour in this case.
However this isn't that easy since the data is quite possibly at different CPUs/cores and in different caches.
A communication step is necessary.

That's the very naive and quite possible much slower algorithm I just came up with.

Another thing you can do is create some sort of distance-function for comparing paths.
So say you have a path A that's terrible. You'll know that a path B that's "close to A" has a high probability of being a bad one as well. (close/far is dependent on the norm you create so to speak)
If another path C is very good (or good) you can restrict your search to it's surrounding. That way you'll always have a good solution(C) and might be able to improve by perturbing the path.

The latter is easier to parallelize with OpenMP. This is as far as I know the quickest way to try and parallelize some code.
If you want to go more into the computer science part where you estimate the cost of your algorithm and benchmark the code, I'm more inclined towards BSP.
Because it has a very simple cost model. And can be used as a gentle introduction to some parallel computing.
 
  • #6
Isn't this just a shortest route problem?
 
  • #8
All such problems are essentially shortest path problems with an appropriate metric applied to each route section e.g. transit time -> fastest route, transit cost -> cheapest route, length -> shortest route.

Dijkstra's method is the classic algorithm but it does not easily parallelise.
 

Related to Pathfinding Routine & Libraries for Slower Areas

1. What is a pathfinding routine and why is it important?

A pathfinding routine is a set of algorithms and methods used to determine the shortest or most efficient path between two points on a map or grid. It is important because it allows for efficient navigation in various applications, such as video games, robotics, and mapping software.

2. How can pathfinding routines be optimized for slower areas?

There are a few ways to optimize pathfinding routines for slower areas. One way is to use data structures, such as priority queues, to store and retrieve pathfinding information more efficiently. Another way is to use heuristic functions to guide the algorithm towards potential paths that are more likely to be successful.

3. Are there any existing libraries for pathfinding in slower areas?

Yes, there are several libraries available for pathfinding in slower areas. Some popular ones include Dijkstra's algorithm, A* algorithm, and Jump Point Search algorithm. These libraries often come with customizable options to optimize for slower areas.

4. Can pathfinding routines be implemented in real-time applications?

Yes, pathfinding routines can be implemented in real-time applications. However, the efficiency of the routine may depend on the complexity of the map or grid, and the speed of the system it is running on.

5. How can I choose the best pathfinding routine for my specific application?

Choosing the best pathfinding routine for a specific application will depend on several factors, such as the type of map or grid, the desired level of optimization, and the constraints of the system. It is recommended to research and test different algorithms to determine which one best fits the requirements of the application.

Similar threads

  • Programming and Computer Science
Replies
30
Views
4K
  • Programming and Computer Science
Replies
15
Views
2K
Replies
9
Views
2K
  • Programming and Computer Science
Replies
4
Views
5K
Replies
6
Views
6K
  • Special and General Relativity
Replies
4
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
Replies
7
Views
2K
Replies
2
Views
2K
Back
Top