Implement pathfinding using the A* algorithm. Works but hangs if the
destination is unreachable.
Add a maximum number of tries, avoids an infinite loop.