Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • 1
    Check out Dijkstra's algorithm, (en.wikipedia.org/wiki/Dijkstra%27s_algorithm) as well as this question. It should help you on your way. stackoverflow.com/questions/430142/…
    – roberrrt-s
    Commented Aug 31, 2016 at 18:12
  • 2
    The A* algorithm would also be applicable here. But note that Dijkstra and AStar only have a better asymptotic complexity than some other options. For example, for a 8x8 grid, a simple Breadth-first-search is likely to be faster in practice (also because it is simpler to implement). The performance advantages of Dijkstra may show up for larger grids, maybe 20x20 or so (depending on many factors - consider profiling them for the real application case!)
    – Marco13
    Commented Sep 1, 2016 at 9:25