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

Partial path finding #28

Closed mikkleini closed 4 years ago

mikkleini commented 5 years ago

Solves #27

If path to the end point is not found then at least a path to closest point is returned. Introduced path finding result enumeration which explain the type of the path:

However, this broke the compatibility. There's no more "GetPath" function, instead there's "TryGetPath".

Looks like this: image

@roy-t - please don't merge yet. I have some TODO's there. I'm mainly thinking about removing agent shape dependent end point boundary check. It might be better to return partial path to end point rather than returning EndOutsideBoundaries error and no path.

mikkleini commented 5 years ago

Removed agent shape consideration from end point check. If agent is too large to get to the end which is at the edge of the grid then partial path is returned:

SquareW3 used in example:

image

giulianob commented 4 years ago

You could keep backwards compatibility with GetPath. Just add back GetPath and make it return null unless it finds a path?

giulianob commented 4 years ago

Also, what would happen if the agent is currently on top of a cell that is blocked? Is that what the "stuck" result is used for?

roy-t commented 4 years ago

Great work, I've re-implemented this in v2, which is under construction :).