Pathfinding on a 2D Grid
The pathfinding algorithm is standard A* with some slight modifications / optimizations.
There are two optimizations that are worth mentioning, the first is that I create the nodes on the fly as that generally helps with speed and less memory overhead, especially so in the case of large open maps with few obstacles. The second optimization is that I use something called a HOT queue which is basically a variant of bucket queues. The HOT queue in my case make the lowermost bucket (since, we want to prioritize the lowest heuristic in A*) use a binary heap, and keep all the other buckets unsorted. I believe this optimization would play a bigger role if the movement cost from node to node was not uniform on the grid, but that is something I might add later on.
The project is available on GitHub here.
If you have any suggestions or comments please don’t hesitate to reach out!