Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deal with different sized objects in a pathfinding situation (A*, A-star)

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?

like image 475
Greg B Avatar asked May 06 '09 08:05

Greg B


People also ask

What is the simplest pathfinding algorithm?

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.

Is A * The best pathfinding algorithm?

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.

What is hierarchical pathfinding?

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.

HOW DOES A * pathfinding work?

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.


1 Answers

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.

  • A 16x16 sized object can walk on a square if that square is walkable.
  • A 32x32 sized object can walk on a square if that square and its' neighbors are all walkable.
like image 176
Martin G Avatar answered Oct 19 '22 08:10

Martin G