All that stuff about making Super AI was Super Interesting, but how is the normal not-playing-games-against-itself-to-try-and-win AI designed & developed?
Ok, so… Game AI is a really deep subject. Like… deep enough that there are professional engineers and designers who are employed full time to make this sort of thing happen. I can’t do the entire subject justice in a small post I threw together in one evening. So instead, you’ll all get a multi-part series on the topic because it’s something I find fun.
Let’s take a look at the eagle-eye view of the topic.
Developing Game AI (Part 1)
Normal game AI is definitely different from experimental/theoretical AI. Experimental AI like Deep Blue, AlphaGO, the UC Berkeley Overmind, or OpenAI are developed to see how far computer learning can go. Game AI is primarily geared towards providing a fun experience for the player. This can have some amount of overlap with experimental AI, but the fundamental goals are different, which necessitates different design and implementation. From the very beginning, we developers establish ground rules for what the AI is supposed to do, as well as its limitations. We have to answer questions like:
Does the AI represent an equal opponent for the player? (E.g. Hearthstone, Chess, Street Fighter)
Will the player fight many AIs at once? Is the AI effectively disposable? (E.g. Dynasty Warriors, Doom)
Will the AI need to cooperate with the player? (e.g. Mass Effect, StarCraft)
Will the AI need to cooperate/interact with other AI? (e.g. Fallout, Skyrim)
Will the AI need to navigate non-uniform terrain? (e.g. Uncharted)
One of the bigger factors to the answers to these questions is how long (we think) it will take us to actually implement these things. We are, after all, always on a schedule. Complicated and extensible AI is great, but not if we can’t fit it into the schedule or budget. Once we figure out the limits of what the AI is supposed to do, we begin with rudimentary design and implementation.
AI development is generally broken into two separate parts - getting the AI to make a choice, then actually executing that choice. These two parts can be (and often are) developed independently of each other.
Making the choice would be figuring out which card to play, which spell to cast, or which ally to heal. Typically, this involves some sort of prioritization system, where the AI evaluates potential options and chooses one based on some set of established rules. Is attacking more worthwhile than using a spell? How about using an item? Should the AI try to maximize its use of mana per turn for tempo, or should it try to maximize card advantage? Which enemy should the AI target for this attack? The most dangerous one? The one with lowest HP? And how do you quantitatively define “most dangerous” anyway?
Executing the choice is the less sexy, but incredibly important part that most fans don’t think about. In fact, most of the design and implementation time for AI in games is often spent making the execution work. After the AI chooses which spell to cast, how does it actually do it? The AI probably has to move into range, which requires pathfinding. The AI has to cast the spell, which means that it can’t be taking damage, unconscious, silenced, etc. The AI might have to consider environmental hazards when pathfinding. The AI might have to consider its location in the world - say that the player is trying to kite an enemy out of its home base, but the game must stream the environment from the disc. If the player goes too far from the enemy base, it will get unloaded from system memory, and likely take enemy with it. How do we handle such cases?
In addition to that, in many games there’s also an even lower level of AI that often needs to work as well. At its most basic level, the character animation system is governed by AI as well. If the player shoots an enemy, it probably needs to play some sort of take-damage reaction, right? How does the enemy know to do that? Something has to prioritize which animations are playing when, and which take priority over what. Dying usually trumps climbing a ladder or casting a spell. There’s generally an AI that handles what animations a character needs to be playing, and when to transition from one animation to another. Remember, the machine doesn’t have any inherent concept of matching motions or positions or anything; any sort of animation transition must come from some sort of set of rules that we create. That also includes keeping track of states like death, unconscious, aggression, snared, which direction to face, etc. and that AI must be able to override or pause the higher order functions too. After all, the AI shouldn’t be trying to navigate to a point on the map if it’s dead.
Building these sorts of systems require a lot of thought and work. The vast majority of developing game AI is spent solving these kind of core problems on a system-wide level. Things like emulating a personality or adding polish touches often come super late (if at all) in the development cycle, simply because getting the core elements to work requires so much time, effort, and iteration. AI can be as simple or deep as we want, but the very basic stuff requires a lot of work to set up.
Next time, I’ll talk about how we get AI to evaluate choices.
Got a burning question you want answered?
Short questions: Ask a Game Dev on Twitter
Long questions: Ask a Game Dev on Tumblr
Frequent questions: The FAQ














