image Chapter 4

Pathfinding

Game characters usually need to move around their level. Sometimes this movement is set in stone by the developers, such as a patrol route that a guard can follow blindly or a small fenced region in which a dog can randomly wander around. Fixed routes are simple to implement, but can easily be fooled if an object is pushed in the way. Free wandering characters can appear aimless and can easily get stuck.

More complex characters don’t know in advance where they’ll need to move. A unit in a real-time strategy game may be ordered to any point on the map by the player at any time, a patroling guard in a stealth game may need ...

Get Artificial Intelligence for Games, 2nd 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.