A brief introduction to the A* algorithm

We'll now look at how an A* algorithm works. In this algorithm, we'll calculate two costs. We'll be taking four pieces of input: our start state (a set of implicitly given states), a state transition operator, a goal state, and the heuristic value of each node. Based on those, we'll be calculating our actual cost, g(n) (which we also calculated in our Dijkstra's algorithm). Along with the actual cost, we'll calculate one more cost: the final cost (f(n)). The final cost will be the actual cost plus the heuristic cost (h(n)). The formula is as follows:

In the preceding formula, the following applies: ...

Get Hands-On Artificial Intelligence with Java for Beginners 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.