Sponsored By
Ron Newcomb, Blogger

May 3, 2016

2 Min Read

When building a game we have the traditional divisions of code: graphics, sound, input, AI, physics, gameplay, and the menus.  Of these, AI tends to be built later in the product's creation because it either depends on other systems working first or it's unclear how to begin.  But does AI need to be its own subsystem at all?  Most game AI falls under one of three types of algorithms: the planner, the pathfinder, and combat.  If AI is not its own subsystem, then where do these algorithms live?

A character-controlling AI can masquerade as a type of hardware controller. Characters, both PC and NPC, are coded agnostically with respect to what hardware or software "pushes their buttons".  AI is then a kind of keyboard or joystick. The AI 'controller' would need gamestate fed to it which the joystick does not.  But in a way the joystick controller does receive gamestate as well: through the graphics and sound outputted to the human who in turn outputs to the joystick.

AI can be viewed as a hinting or how-to-play system taking its own advice.  If the hint system advises pressing Jump to bypass an approaching chasm or highlights where to stand in relation to a mobile opponent, then it is capable of pressing the buttons itself. The harder part was knowing when or where to act, not the difference between describing or performing the act. 

AI can also be viewed as physics.  An enemy patrolling back and forth in a platformer moves the same way as a moving platform does, but we'd be tempted to use AI for one and physics for the other. We think of things like gravity and momentum as outside forces acting upon us while dashing and jumping as forces from within because that's how reality works, so of course we tend to code it the same way. But it's all just movement and state changes as far as the code cares.

Many first-time videogame creators tend to save AI for last because it is the least obvious how to go about doing so. Their libraries of code have ready-made functions for graphics, sound, and input, but even if there's a pathfinding function on offer, it's not entirely clear what to do with it.  Viewing AI as extensions of other systems is a simple way to demystify it.

Read more about:

Featured Blogs

About the Author(s)

Daily news, dev blogs, and stories from Game Developer straight to your inbox

You May Also Like