Possibly helpful link: A* search algorithm: https://en.wikipedia.org/wiki/A*