When it comes to AI, most gamers are happy with scripting that essentially escapes notice entirely by not doing anything particularly stupid, cheap, or annoying. By the same token, they’re often thrilled by the bad guys, AI teammates, and random NPCs that somehow simultaneously enrage and impress them by doing something clever, original, or downright evil that they wish they’d thought of first.
My first session of GDC 2012 was a postmortem from a handful of folks devoted to delivering on a little bit of both for their respective titles, and while most of you will never have to worry with the ingenuity lying underneath your favorite interactive experiences, Skulls of the Shogun’s Borut Pfeifer spent the better part of the last year or so improving the AI behind the upcoming XBLA strategy game in the hopes that you’ll learn to respect your opponent.
Noting that most games don’t fail to think of slick routines for their computer-controlled baddies, Pfeifer explained that they just fail to follow through by debugging all the potential cases where they might do something stupid, often leading to a lesser challenge in a genre that lives and dies by its decisions.
“It’s a frustration for games in the genre. The AI [in most games] isn’t necessarily that great,” said Pfiefer. “But for Skulls, it was important for me because I’ve focused on AI in the past, and I wanted to make it good. Our gameplay was different; it wasn’t very rock-paper-scissor-y, so it needed to deal with a range of tactical situations. It’s sort of a blend of real-time strategy and turn-based strategy, and I think we ended up with a pretty good solution.”
In his portion of the talk, Pfiefer explained that one of the keys to avoiding common pitfalls found in other strategy titles was failure to avoid cases of outright stupidity. “Most flaws in game AI typically stem from the architecture not dealing with errors,” he explained. “It’s kind of the cause of most glitches your average player will see in games. Any representation of the world that the AI can reason about will have some sort of error with the way it actually is. So, being able to deal with error and pass it up to a higher level where the AI can redirect and adjust its behavior is supercrucial to being able to avoid those sorts of problems.”
And while his co-lecturer Daniel Baker faced a different set of difficulties while working on The Darkness II, his team at Digital Extremes faced their own set of difficulties while working to make the game’s AI goons seem as intelligent as possible. Oddly enough, this included tech that made them smart enough to be a bit…well, a bit stupid, as the game actually slowed their reactions to threats coming in and out of the shadows.
“We wanted our agents to respond in a much more natural manner to the stealth gameplay,” Baker confessed. “We didn’t want an instantaneously transition going from idle to ‘full Rambo’ just because you stuck your head around a corner. So, instead, our agents build up a knowledge representation of their targets. They remember things, like if they can see the target right now, if they can hear him. Is he actually making noise right now? Have their teammates told them about him? All this stuff feeds into an importance score that we give to each target, and the more perceptions they receive about a target, the more the importance ramps up over time. When we stop receiving perceptions, the importance decays down.”
This allowed the team to trigger reactions after a set threshold was reached, essentially ignoring more subtle actions by the player, giving you the opportunity to make a few mistakes without the game biting your head off. You may not think about it in the heat of battle, but this just goes to show how programmers work to ensure that each moment is as dynamic and fair as they can manage.
The funny part was, when Big Huge Games’ Michael Dawe took the stage, it became apparent that guiding the player and the AI’s reaction to your inputs were often the least of the team’s worries, as another element introduced even more chaos that either one combined: the design team.
“Designers are crazy,” said Dawe. “They will do everything. You’ll write functions where you’re like, ‘This is such a hack. I know you need it for this boss creature, but never use it anywhere else because that’s all the time I’m gonna spend on it.’ But they’re gonna use it on [something else] and then ask you why it doesn’t work, and you’ll end up having to support it anyway.”
This revelation got a lot of laughs, but it also went a long way to show that building good AI isn’t just about what you know you want your NPCs to do. It’s also about knowing what you don’t want them to do, or sometimes, it can be about how quickly or slowly you want them to get about the business of doing it. And beyond that, it can also be about what you do on your end when you realize someone tricked them into doing it.
And that’s not even the half of it.
Kind of makes me glad I get to play this stuff these days, as opposed to pushing past all the headaches involved in making it work to ensure that the rest of us can just sit back and enjoy ourselves. Clearly, it’s time to go buy a random AI programmer a beer…