Search code examples
language-agnosticpath-finding

Given two positions, and a list of all positions, find quickest path


I have two points (x1, y1) & (x2, y2), and a list of all possible positions that can be traversed across with format (x, y), how would I find/estimate the quickest path between the two values.

I am implementing this in Java, but the language doesn't matter much.


Some limitations & additional info around the question:

  • The values of x1 & x2 will be never the same, unless y1 = y2, this is because these positions are always located on the edge of a box.
  • There may not always be a path between (x1, y1) & (x2, y2) (for when checking for continuity between the paths
  • Not all possible points will be connected to either (x1, y1) or (x2, y2)
  • Shortest path isn't required but would be handy to know
  • Would be happy with simply some hints about what direction to take or algorithms to look into
  • Travel can happen via a diagonal ((x, y) & (x + 1, y + 1) are considered neighbours)

Solution

  • The answer I was looking for is to use A* as a search algorithm, this finds the shortest path between two points given a map of all the nodes.