I'm working on a game that uses A-star (A*) for path finding but I've come to a point where by I have some objects that are larger than a single grid square.
I'm running on a grid of 16*16px. wall segments are 16*16 and so make a single square impassable. Some of my baddies are 32*32 and so they need to check that a gap is at least 2 grid square wide in order to be able to pass throguh it.
I can't simply make the grid 32*32 as the design requires thin walls (at 16px) and there are a couple of smaller baddies that only take up a single 16*16 square.
How do I implement this mutli-resolution environment? Is A-star still the correct tool to use?
Dijkstra's Algorithm is another algorithm used when trying to solve the problem of finding the shortest path. This algorithm specifically solves the single-source shortest path problem, where we have our start destination, and then can find the shortest path from there to every other node in the graph.
A* is the most popular choice for pathfinding, because it's fairly flexible and can be used in a wide range of contexts. A* is like Dijkstra's Algorithm in that it can be used to find a shortest path. A* is like Greedy Best-First-Search in that it can use a heuristic to guide itself.
Hierarchical path-finding aims to reduce the number of nodes that need to be explored when computing paths in large terrains. The reduction in the number of nodes for higher levels of the hierarchy significantly decreases the execution time and memory footprint when calculating paths.
A* algorithmA* assigns a weight to each open node equal to the weight of the edge to that node plus the approximate distance between that node and the finish. This approximate distance is found by the heuristic, and represents a minimum possible distance between that node and the end.
For a relatively simple solution, I would stick to the same A* algorithm as for 16x16 sized objects but with a slightly different way to evaluate if a square is walkable or not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With