Search code examples
javaandroidpath-finding

Android - Pathfinding on map.png


Good morning,

I'm working currently on a pathfinding project. Basically, I got this map on my application :

enter image description here

And so I just want to determine the shortest way to go from A to B (of course, I can't go through the blue and gray part which are basically walls...)

Is A* algorithm a good way to start ? Well if you have any ideas, any suggestions about this problems, tell me ^^

Thank's for your help !


Solution

  • Yes, A* is a good start, assuming you mean to allow movement on the grid only. I mean an agent on a pixel would only travel North, East, South, West and never diagonally. Be warn you will obtain rather un-natural looking paths with 90° and 45° angles everywhere, but this can be mitigated later using some appropriate tie-breaker.

    I propose you start using Dijkstra, and once you got that working modify it to implement A* - both algorithms are very close.


    If instead you intend to allow your agents to travel diagonally from any pixel to any other pixel which has direct visibility, then no, an other algorithm is needed.