Revisiting the A* algorithm

Let's review the A* algorithm again, before we proceed to implement it in the next section. The foundation of any pathfinding algorithm is a representation of the world. Pathfinding algorithms cannot search over the noisy structure of polygons in the game map; instead, we need to provide them with a simplified version of the world in which we identify the locations that can be traversed by the agent, and the ones that are inaccessible.

There are many ways of doing this; however, for this example, we will use one of the most straightforward solutions: a 2D grid. Therefore, we will implement the GridManager class in order to convert the real map into a 2D tile representation. The GridManager class keeps a list of ...

Get Unity Artificial Intelligence Programming - Fourth Edition 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.