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

RFE: Generify the pathfinder to allow costs as integers instead of floats #11

Closed Brannalbin closed 6 years ago

Brannalbin commented 6 years ago

Floats seem overkill for many scenarios so it would be nice to be able to use int's, too.

roy-t commented 6 years ago

That sounds like a good idea, but making the PathFinder generic is something I experimented with before, and it will reduce the performance more than the benefit of being able to use an integer. For an integer pathfinder I would need to duplicate most of the code. Not necessarily an insurmountable obstacle. But do you think performance is not good enough right now?

(This testing was several years ago on an older A* implementation, results might vary :) )

roy-t commented 6 years ago

Another question would be. Do we really need integers, or are in this case bytes enough?

roy-t commented 6 years ago

After thinking some more about this, I think its not a good idea. Using integers or bytes will not give you the ability to make cells only a little bit more expensive. The memory consumption for floats and ints is the same and even on the processing side I'm not sure if it will gain much as CPUs are very getting better and better at doing floating point work. (Though I think it still costs multiple cycles). :)

If you see other reasons, please feel free to re-open this ticket.