A* Search

In the preceding section, you learned that the path found by a greedy BFS is as follows:

Figure 19

The total distance covered is 14.24. However, the actual optimal solution is shown in the following diagram:

Figure 20

The total distance covered is 12. This means that the greedy BFS algorithm is not optimal. The problem is that the heuristic function doesn't consider the costs already incurred. A* Search proposes a new heuristic function, which computes the sum of the cost incurred and the estimated cost to reach the goal state.

Get Hands-On Artificial Intelligence for Search now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.