Entry #10 - 11/12/01
By Karl Burdack
Senior Programmer, Irrational Games
Hi there, my name is Karl Burdack. My role on the Freedom Force project is senior programmer. I'm fairly new to the team, having been here since June this year. One of the tasks I've had to get up to speed with is the AI, and that's what this diary is about. I intend to give the reader some idea about the design of the AI, but also an insight into what the game's single-player experience is like with respect to its AI.
First of all, what is AI? It is supposed to represent "artificial intelligence." However, typical implementations in games don't exhibit true intelligence, but rather a close approximation, as we have in Freedom Force. The Freedom Force AI is actually composed of a few layers of control mechanisms, ranging from the high-level goal-tactical decision making to the low-level control of animation, movement, and power launching--with each higher layer controlling the layer below it. What I want to discuss is the highest level of our AI: goals and tactics.
It's worth noting that game AI is not "real" AI. The point is not to make the smartest, most realistic characters ever. The point is to make characters that make for good gameplay. By not attempting to make "realistic" characters (which is impossible), we freed up a lot of time for ourselves to work on making the game characters work with the game systems and serve the overall game design.
The starting point for the design of the AI was the question of how we wanted the characters to behave. In general, we preferred consistent behavior that would be predictable enough so that the player would learn what to expect from AI characters. We wanted players to learn ways to exploit deliberate weaknesses in the enemy AI tactics. We also wanted each kind of opponent to be distinctly different. In a way, each different AI is like a puzzle to solve. The puzzle will have many solutions depending on which heroes you recruit and the powers you purchase.
The designers had come up with ideas about how they wanted different minions and villains to behave, as well as the intended solution to defeating each of them. In design meetings, we would negotiate what we thought we could do technically and then implement this in the AI code. Our solution was to write a slew of discrete tactics, each of which could be tested independently. We would then mix tactics together to produce the required behavior of any AI.
For example, aliens have a ranged attack and a shield and are able to fly, but they aren't very good at melee combat. The designers required the alien to cowardly shoot a ray gun at heroes, and when a hero such as Man-Bot is near enough to punch them, they would fly away. Also, the alien would use a shield power against any ranged attacks. The solution the player might use is to attack an alien with two ranged attacks at once. Or distract the alien long enough with ranged attacks so that a melee character could wallop them. The alien AI is constructed from a bunch of tactics, including ranged attack, shield defense against ranged attack, fly away from melee attacks, fly away from area attacks, and flanking maneuver. All of these tactics were implemented generally and are also used for other AIs. But the combined effect of these tactics produces the behavior that the designers were looking for above.
Because we implemented each tactic separately, we were able to reuse a lot of code when writing new AIs. In fact, toward the end of implementing the AI, most of the work involved deciding what existing tactics they should use and implementing about five lines of code to link them up. This saves us not only on development time, but also on debugging and testing time, since once a tactic works on one character, it usually works correctly on others.
The other component of the high-level AI is goals. Goals are like an AI's very simple memory of tasks it needs to complete. Every character can be assigned a variable number of goals, and each goal is assigned a priority. Higher-priority goals are executed first if possible.
For example, the designers might assign several destroy-building goals to a number of Mech men. Not having anything else better to do, they will happily go on a destruction rampage and destroy those buildings. If a hero turns up, the Mech men "kill heroes" goal will become possible, and depending on the priority of the different goals, they may choose to attack the heroes instead. In this example, the designers assigned the goals with equal priority, which means the Mech men fall back on comparing individual goal-tactic pairs that are possible, decide which combination is best, and execute it. Without going into the complexities of this decision process, the end result is that the Mech men usually choose to attack the heroes instead of buildings.
The only time the AI behaves in a scripted way is when being guided by goals. And even then, the goal is only a very high-level description of what the AI should do. How the AI executes that goal depends on its tactics, abilities, and the environment around it. It was a conscious design decision that for our AIs to properly react in the dynamic environment of Freedom Force, they also must be general and as nonscripted as possible. For example, almost everything in the world is destroyable, including buildings, cars, other objects that can be moved or thrown, civilians moving all over the place, and characters that fly or jump high. There are many possible situations an AI can encounter, and we wanted them to react in a suitable way.
It's a rewarding feeling having written some general solutions or rules for an AI to follow and then seeing them react in an acceptable and sometimes surprising way to circumstances you never considered.
Expect to see characters in Freedom Force to exhibit distinctly different tactics. Part of the experience should be figuring out how to defeat these characters under different circumstances. Players are required to develop their own tactics to counter those of the AI. Also, expect to see AIs with a purpose, as well as reactive behavior.