Dr. Ian Davis, self confessed mad scientist and the mind behind the AI in dozens of top games, including Empire Earth II, talks the about the art of AI and what it means for the future of games.
Atomic Let's start at the beginning -- writing AI for games sounds like both the coolest and hardest of jobs. How did you get into it, and do you enjoy wrapping your head around it?
Dr Ian I’ve been writing games for myself since I was a kid, and as I got older I found AI to be the most interesting problems for games. Graphics are tough, to be sure, but it’s well understood what it should look like and roughly how to get there (and most of it comes down to hardware). AI is the real frontier in games – each game needs different AI and there’s no real blueprint for how to do it.
I was in grad school getting my PhD in Robotics (AI) when I realized that games presented all of the same cool AI challenges as robots but without requiring you to solve the hardware and low-level perception problems first. Someone I knew from high school had a contact at Activision and they put me in touch, and that was how I got started. It’s been a long road from that to my latest game, Empire Earth II: The Art of Supremacy, and a lot of cool AI has been made in the process.
Atomic Where else do you apply the science outside of games?
Dr Ian I have a few other outlets… My company does a fair amount of research (military and other) on government grants. Also I am currently teaching a course on virtual characters at MIT in Cambridge, MA.
Atomic Speaking of which, AI in games today is one of the biggest letdowns. Fancy graphics, great story, and superb gameplay can all be let down by walnut-brained enemies. Why is this? Is it just impossible to actually create, or is the challenge creating intelligence that can run without taxing the CPU?
Dr Ian The biggest problem is that most companies simply don’t devote enough resources to AI soon enough. Graphics get you noticed and bright and shiny things grab marketing people’s attention, so AI gets put off to later – in fact, too late. Most companies also don’t have someone trained to think about AI. Most AI programmers at most game companies wouldn’t pass muster here (they may be good programmers, but there’s a lot of AI in the universe, and if you haven’t studied it, you’ll end up reinventing the wheel).
Atomic On a related note, pathfinding in games often ranges from shockingly bad to total crap. Why is it so hard to calculate a path from A to B navigating around objects?
Dr Ian It’s only hard when you don’t know what you’re doing (or if there’s hundreds of units moving at once!). Basic pathfinding for a FPS or action game is a simple problem to solve, but Navpoints is not the way to solve it. It’s appalling how many game engines use that technique, which is mathematically guaranteed to suck. You need to know how to decompose spaces into appropriate convex regions, how to do searches more advanced than barebones A*, and how to handle units moving together or in proximity.
Atomic Where's the first place you start when designing AI for a game -- exactly, how do you build an 'intelligence' and what are the parameters that define it?
Dr Ian It depends a lot on the nature of the game. An FPS clearly has different needs than an RTS.
Of course, there are some commonalities: every game needs some sort of pathing system. If you can’t move from A to B, you can’t seem smart. To design this, you need to consider the structure of the underlying terrain. In a strategy game, you may be dealing with tiles underneath, while an FPS might have arbitrary polygons. The goal in any pathing system is to decompose the free spaces into the largest possible convex regions (convex because you’ll be planning routes between cells and want to know you can move freely in a cell). Once you’ve decomposed the space, you need to extract a directed graph from it on which to perform A*. Don’t do A* directly on the geometry… the abstraction is important and gives you lots of flexibility for adding special connections. On the back end, you need some sort of rubber banding system to make the path look more natural, and some sort of dynamic collision avoidance to handle moving objects while still trying to follow your path. And you need to consider moving in formation with other units, too.
On top of all that, you’d build your core AI systems. For an FPS, you’d need a character logic system (inference engine, production system, state machine, whatever). For an RTS, you’d need a system to allocate resources (troops) to tasks (attack the enemy, defend your base, etc.). In an RTS it becomes almost an operating systems problem: how do I accomplish this, this, and this, with just these resources.
Atomic In computer science terms, what exactly are the building blocks of an intelligence?
There’s no formal definitive definition of an intelligence. You could enumerate things like a logic center, a memory, sensing, and the like. But to paraphrase and twist from Forest Gump: smart is as smart does. What I mean by that is that the goal of a game AI is (for an opponent) is lose convincingly. Your AI opponents are tools for drama and tension as much as they are intelligent agents. An AI must do things for logical reasons, but also be unpredictable. Most importantly, the player wants the AI to be good, so the player will actually help you out in some ways in coming up with explanations for the AI’s behaviour.
If you want to get down to it though, let’s list some general components:
• Sensing. The AI must have some way to gather information about the world. If the AI has complete knowledge even when it shouldn’t, the player will notice. But on the other hand, if the AI ignores the obvious (to a human… like another AI getting shot), the player will notice that, too. And sensing isn’t just raw data… you need to process it to get it into a manageable form. In a strategy game, having a list of known enemy units isn’t enough; you need to suss out where the concentrations of enemies are and what areas are threatened by enemies before you can even begin deciding what to do.
• Logic. This varies by game type, but you clearly need to be able to choose a tactic, allocate troops, or perform some analysis of your data.
• Memory. An AI must behave in some coherent way with the knowledge it’s already acquired. In a strategy game if you see enemy units but then they go away, the AI must be able to extrapolate where they might be or at least be aware that there’s a threat out there.
Atomic How do you test a game's AI and make sure it doesn't do anything you didn't expect it to be able to do?
Dr Ian This can actually be very tough. On Empire Earth II: The Art of Supremacy we had testers working on it from day one at our offices in addition to the testers from Vivendi. In some ways you want the AI to be somewhat predictable, but you also can’t make the testers’ jobs too hard, that can create additional problems, too. There is no hard and fast rule, but the best thing to do is to make sure your AI engineers and your testers talk a lot. When the engineers implement something, the testers should shake it out right away.
Atomic Generally, what language do you build or write a game AI in?
Almost all games are written in C++. We have our own proprietary scripting language that’s part of the MadAI® suite of AI tools we use that is very fast and very efficient!
Dr Ian What games have you worked on and contain your work? Which are you most proud of?
I’ve worked directly on Dark Reign, Battlezone, Civilization: Call To Power, Call To Power 2, Star Trek Armada, Star Trek Armada 2, Dungeon Siege: Legends of Aranna, Jane’s Attack Squadron, Empire Earth: The Art of Conquest, Empire Earth II, Empire Earth II: The Art of Supremacy, and several others. I’ve consulted on the AI for games such as The Suffering, Ground Control 2, The Sims 2, Lords of the Realm 3, and others I can’t name. We also have a number of products currently under development. I’m proud of all of them, but especially excited about what we did with Empire Earth II and Empire Earth II: The Art of Supremacy. Some of our new games in development will set new standards for AI, too.
Atomic What games do you think are examples of exemplarary AI, and what games have AI so bad it makes you embarrassed to be in the field?
Dr Ian A game like The Sims did a lot for AI, and I’d love to see that sort of dynamic brought into a more traditional, more ‘type A gamer’ game. I’ve played a couple of RTS games where the AI didn’t pay resources for its units, teched up whenever you did, and knew what units you had automatically and then built exactly countering units for free. You can tell quickly that this is the case, and it ruins the game because none of the strategies that are part of playing the game make any sense against such an AI.
Atomic Do you think a program, regardless of complexity and the resource of the hardware on which it runs, in the future, could achieve the equivalent of sentience?
Dr Ian Yes. Not soon, but eventually.
Atomic What's the most fun you've had designing AI -- is there anything you've made that you can class as 'alive'?
Dr Ian I really had a great time designing the AI for Dark Reign. It was my first strategy game and I made lots of mistakes, but it was great to see the problem in that first light of understanding. On the other end, it’s been great to see all of my techniques evolve into the far more sophisticated AI found in Empire Earth II. It’s amazing how far I’ve come in building on my earlier ideas.
Atomic Do you have any anecdotes of in-game behaviour you didn't expect or surprised you?
Dr Ian At one point in developing Empire Earth II we noticed the AI wasn’t breaching walls very well, so we turned that task over to one of our best engineers, and then in the next day’s build the AIs just obliterated every wall with a vengeance bordering on the psychopathic. No defense was safe because the AI can target more wall segments at once than any human can hope to. We had to dial it back, because it was like cartoon termites tearing through walls like a buzzsaw!
Atomic What education do you need to get into this field, and even then if you have a degree, how do you actually get a job writing AI?
Dr Ian You need a BS in Computer Science, minimum. A masters or PhD will help. You need to study path planning, search, logic and decision making, sensing, personalities, and a dozen other things. If you try to learn AI at a job on the job, you’ll always have too much pressure to finish a task RIGHT NOW, and you’ll never get to explore all the options. In short, you won’t learn efficiently.
Atomic When will Shodan become a reality?
Dr Ian Oh, you’ll know when…you’ll know… (evil laugh).
Atomic Anything else that we may have skipped (not being experts in the field!) that you think would be interesting to our audience?
Dr Ian Getting into the game – if someone wanted to get into the field of AI, where should they start?
Atomic It’s worth noting that lots of universities are starting to offer courses in game development If you’re studying somewhere, let them know that a course in Game AI would be valuable. If enough students say so, they’ll find a way to offer one. I’m currently writing a book on the topic, so they’ll have something to teach!
Dr Ian I also just want to thank you and your readers for the opportunity to say hello. It’s been a pleasure. And don’t forget: The Art of Supremacy is due in 2006 – check it!
Dr. Ian Lane Davis, former Technical Director at Activision’s Santa Monica studio, is widely acknowledged as one of the top Artificial Intelligence experts in the video game industry. His direct game credits include: the eagerly anticipated Empire Earth II: The Art of Supremacy (due 2006), Vivendi Universal Games; Empire Earth® II, a PC Gamer Editor’s Choice award winner garnering a 94% review score, (2005), Vivendi Universal Games; Dungeon Siege®: Legends of Aranna™, an Academy of Interactive Arts and Sciences "Computer Role Playing Game of the Year" finalist, (2003), Microsoft Game Studios; Empire Earth: The Art of Conquest™ (2002), Sierra Entertainment; Jane’s® Attack Squadron (2002), Xicat Interactive; and for Activision Publishing, Inc., Star Trek®: Armada II™ (2001), Call to Power II (2000), Star Trek®: Armada™ (2000), Civilization®: Call to Power™ (1999), Battlezone® (1998), Dark Reign: Rise of the Shadowhand™ (1998), and Dark Reign: The Future of War™ (1997).
Active in the game community, Dr. Davis serves as a Peer Panel Leader for the Academy of Interactive Arts and Sciences Peer Panel for Gameplay Engineering and is a trusted advisor to key industry publishers. Currently authoring the definitive AI and games textbook for academic and industry training along with academia’s top AI researchers, in the fall of 2005 he accepted a guest professorship at MIT, teaching “Characters in Video Games,” a topics in comparative media studies course. Recently appointed Editor-in-Chief of the Journal of Game Development, he is a highly sought after speaker who presents in academic and game focused venues and has been interviewed for print, online and television media.
Davis earned his doctorate in Artificial Intelligence and Robotics from Carnegie Mellon University, one of the nation’s leading computer engineering schools. Here, he applied his talents in Artificial Intelligence to autonomous cross-country navigation in the Highly Mobile Multi-Purpose Wheeled Vehicle (HMMWV) for the Department of Defense, researched the inspection of aging aircraft via the Autonomous NonDestructive Inspector (ANDI) for the FAA, and analyzed and designed systems for the Lunar and Earthbound Lava Tube Explorer. For a comprehensive look at the Doctor's books, publications, speeches and more, visit our AI Specialization page.
In 1999, Dr. Davis founded Mad Doc® with the goal of developing Triple A titles that expand the game playing experience and broaden the market through creative use of new Networking, Graphics, and AI technologies (Empire Earth® II uses Mad Doc’s Mad3D™ Game Engine and MadAI™ technologies). With Davis at the helm, Mad Doc has quickly become an emerging force in the industry. The team consists of industry veterans with experience in every aspect of game development and an unmatched expertise in Artificial Intelligence. A registered Xbox®, Xbox 360™ and PlayStation®3 developer with a proven record of strong game design and on-time, on-budget delivery, Mad Doc team members are collectively responsible for over 10 million units in the game market worldwide. Currently, Dr. Davis and the Mad Doc team have several titles in production.