roy-t / AStar

A fast 2D path finding library based on the A* algorithm. Works with both grids and graphs. Supports any .NET variant that supports .NETStandard 2.0 or higher. This library has no external dependencies. The library is licensed under the MIT license.
http://roy-t.nl
MIT License
340 stars 60 forks source link

Finding closest path to unreachable end cell #27

Closed mikkleini closed 4 years ago

mikkleini commented 5 years ago

It would be nice if the end cell is unreachable that the algorithm still provides path to the closest reachable cell. Like this:

image

juliolitwin commented 5 years ago

Thanks, I was looking for a similar feature!

roy-t commented 4 years ago

Sorry for my late reply. You even made a PR which I never commented on, my bad :(. I've used your ideas in the v2 version (under construction) of this library. The v2 viewer is almost finished I think. But I still have to do a lot of performance improvements, and I have to figure out if its worth it to have a path finder for graph and for grids, or if the graph one can accommodate grids good enough.

Sneak peek (also on the master branch, if you want to play with it).

Capture

mikkleini commented 4 years ago

Looks advanced :) But i'm not sure I understand the heatmap without looking deeper at the code. Is it some kind of precalculated weight of edges to speed up path finding?

I think the graph/grid choice depends on the application. Me for example used your algorithm on autonomous robot. Since it couldn't take precise sharp turns like you would see on the calculated paths and it was important to not hit anything, then maintaining clearance from obstacles was important and that's why I added agent shape feature. But if you are going to have nodes on any X-Y coordinates then I find it complicated (and computationally expensive) to take agent size into account in graph approach.

roy-t commented 4 years ago

I've released a new version today (https://www.nuget.org/packages/RoyT.AStar/3.0.0). Please check out the readme.md file in the root of this repository. It also includes some tips for different agent sizes.

And last but not least, it includes a feature for finding incomplete paths!