This is exactly how the A* pathfinding works; it goes from point to point evaluating the best options and pursuing the shortest path until it reaches the final destination. The earlier example was simple, and now we are going to make it more interesting to see how it works if we add obstacles to the map.
Using the same map, we have painted some squares in black, representing that those positions can't be used. Now, it starts getting slightly more interesting, because if we try to guess what the best path to take would be, we might be wrong. Once again, let's calculate what the best options are, as ...