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
338 stars 60 forks source link

Prevent cutting corners #16

Closed Dan-Matt closed 5 years ago

Dan-Matt commented 6 years ago

This isn't really an issue, it's more of a feature. I was having a problem in that the path will cut corners instead of finding the way around. This is probably standard A* behaviour but I needed it to work a bit differently for a game I'm working on. I forked the code and made the change. https://github.com/EnderYoss/AStar/commit/c1633de8f2315c581e2005ab0e994151cecaf661

I just thought I'd let you know in case you wanted to use it or adapt it. The difference can be seen here- astardiagram

Dan-Matt commented 6 years ago

Just to reiterate - I don't mind if you include this feature or not I just wanted to make you aware of it! Thanks

roy-t commented 6 years ago

Ah I actually had a 'cutCorners' option in a really old A* version (https://roy-t.nl/2009/02/24/implementing-a-path-finding-in-c-and-xna-source-code-can-we-cut-the-corner.html). I didn't implement that option in the new version yet. I think the way you've done it, only checking late is pretty smart. I'm not sure if I want to integrate it yet. But I'll keep this ticket open.

Thanks a lot!

Dan-Matt commented 6 years ago

Right okay fair enough! Thanks for the feedback - no problem!

roy-t commented 6 years ago

I've thought of another option that might solve this. See #18, no ETA though :)

Dan-Matt commented 6 years ago

Sweet sounds good I'll be following this!

rallianto commented 4 years ago

This isn't really an issue, it's more of a feature. I was having a problem in that the path will cut corners instead of finding the way around. This is probably standard A* behaviour but I needed it to work a bit differently for a game I'm working on. I forked the code and made the change. Dan-Matt@c1633de

I just thought I'd let you know in case you wanted to use it or adapt it. The difference can be seen here- astardiagram

How did you achieve that I am interested to know?