Hello again, just finished the third part and here it goes!
Once more, I’m sorry for it taking so long. My last few weeks before Christmas are also pretty busy. I probably wouldn’t be able to finish the last part during the next week, but I will make sure to have it ready by the last weekend before Christmas (in two weeks).
Have a nice reading until then!
Translation: @bebuce
Proofreading: @PhanTom_CZ
Artificial intelligence in games #3: Nobody wants a smart AI
How is the third Arma going to deal with teammate’s AI?
Cooperation
Mutual cooperation of its entities is a difficult task for an AI. Most players would probably think of a special forces squad advancing by-the-book in a perfect formation. In reality it all actually starts with the NPCs not walking into each other’s line of fire, in everyone not trying to take cover behind the same crate, or in sharing the player’s location.
Of course, the commercial AIs can do even the advanced show-offs, just like a squad moving in a perfect formation, or a crowd scene simulation with a thousand of figures pushing each other. If you take a look at a presentation demo of Kynapse AI, you will see how nicely it works.
What’s the problem then? Why do the NPCs in most games just limit themselves to popping up, spraying you with an unlimited amount of ammo and then going down after a single hit, while your mates are keeping their respectful distance somewhere behind and are capable only of getting stuck somewhere, or running straight into your line of fire to get accidentally killed? The veterans will now shed a tear in the memory of meeting the special forces in Half-Life for the first time and those crazy maneuvers of your enemies in F.E.A.R. Why don’t games make use of all that today’s AI can do?
Game versus reality
The thing is that the game is not reality and the goal is usually not to create a perfect simulation of some complicated activity, but to simplify it so that even a normal, untrained person can try and “live” through it. The creator has to find a balance between the game being a challenge, while also being entertaining rather than frustrating at the same time, so that the player has a good feeling from his accomplishments.
Everyone who ever tried multiplayer, airsoft, paintball or an actual war knows that to kill a living enemy is much, much harder than in any FPS game and we are not even talking about the moral difficulty of such an act, but about the very struggle to win. If you happen to face several well coordinated enemies just on your own, you’re practically helpless and good feeling is the last thing you will get.
I recently tried that out by myself in a paintball pistol tournament of three-person squads. The moment when you’re alone against three cooperating opponents is when you’re screwed, as you can’t cover three directions at once and any intelligent opponent of course surrounds its pray. The victorious team managed to get through nine matches without losing once and even with a single casualty, (which, as it happens, was my only kill in the tournament worthy of a record :).
Yet the basic premise of most games is the player standing alone against a huge swarm that he has to overcome, which puts the designers to an almost hopeless situation. The players are calling for awesome artificial intelligence, but if they got it, the game would be unplayable and vast majority of players wouldn’t like it at all.
The simplest thing the designers can do for the player to make his fights with the NPCs easier is to give him an advantage. Usually by giving his avatar some more endurance. This, however, leads to another undesirable outcome - the AI, set to expect its enemy to die after getting hit, would be somewhat “taken by surprise” that the player didn’t die and keeps on returning the fire with joy.
What now? If we leave the NPC standing in place and shooting until the player drops, that eliminates the original advantage we gave to the player. If the AI runs from the player, it would look stupid and we are back where we started.
If you count in the teammates on the player’s side, which are usually important for story progression, so they shouldn’t die, we are already quite far from achieving some believable simulation. Most designers don’t want the teammates to be able to achieve victories for a passive player and on the other hand they are also trying to avoid getting them killed, so that the player would not have to restart the level angry, for the failure was not his fault.
Probably everyone can recall the absurd situations in lots of games where you have a crowd of mutually antagonistic characters running around in a small space, everybody shooting like crazy, yet nobody dies. This is a result of exactly those problems. Another natural advantage the player has is to be able to repeat the part where he had a problem. The player knows what to expect and can use it to his advantage, while the AI starts fresh with each restart.
Do you remember HECU? Some people have the enemies from Hazardous Environment Combat Unit in Half-Life games chasing them in their sleep to this day
Imperfect reality
This raises a question of what should be called “realistic” and what is an “error”. If you go watching real people in a multiplayer game, you will probably see a lot of funny situations - friendly fire, throwing grenades under their own feet, pointless running around… If an AI does that, we would consider it a bug. Yet similar mistakes happen even in the real fights.
Friendly fire is a very serious issue in every war and who thinks that soldiers can’t get lost probably never tried walking in the woods with a map. Does it bother you that your teammates in Flashpoint react differently to your commands than you expected? You should try commanding some real people in a similar situation, you would quickly realize that they often behave in even more unpredictable and stupid ways than their computer variants.
It’s no wonder then that game designers started to focus on scripted coordinated puppet plays. We could use most introductory missions in Call of Duty as a good example. The designer gets a task to create a scene were the player’s unit storms a building and neutralizes the terrorists inside. If he decides to script that, it means he has to painstakingly develop every second of the action. He needs to set up all the animations for each soldier and time it carefully.
There was a lot of hype about F.E.A.R before its release and it has been quite justified afterwards
Everything in-game has to be set up so that the player couldn’t break it. A great thing is that if you can motion-capture it all, the final scene will look absolutely fantastic and only a few things could go wrong. The downside is that it will remain the same every time and the player will soon realize that he’s not really a player, but just a viewer.
Only few choose to go the other way, taking an AI, giving it a task and letting the things unfold on its own. To stand up in scrutiny against the scripts, the AI must be able to perform some visually impressive macho actions - to kick out doors, to take cover behind obstacles, to tilt while running in an arc… in short, to have perfect animations.
The drawback is that the animation sequences synthesized in real time from prepared universal moves can’t compete with a script which often uses animations that were captured for that scene specifically. The clear advantage is that every playthrough can be completely different and the player has a huge freedom of action.
Everybody makes mistakes. Who knows if that Korean that keeps crashing into the fence isn’t just under the influence of North Korean ideology and does it on purpose
Every script has its purpose
The main issue and I dare say the main reason why most developers prefer scripting over creating a solid AI is that the result is largely unpredictable and it can turn against its creators. Even if you put all that you can into testing and QA, you can never be sure what would happen and the more freedom the AI has, the more likely it is that something won’t happen the way you wanted.
Crysis 2 can serve as a proof. The creators were boasting about their most advanced AI ever to be found in a game, yet they got ridiculed. Every NPC that got stuck, threw a grenade under its feet, or couldn’t react properly to the player, was used against them as if they were lying. With a bit more exaggeration you could say that this kind of mockery is similar to someone ridiculing the God for having created people who suck at playing Counter Strike.
The environment in current games is usually huge and the AI, like the one in Crysis 2, simply does what it wants. A certain amount of errors, embarrassments and troubles is almost inevitable. Just like the players do make mistakes, so does the AI. Although, of course, this should be happening as rarely as possible.
Dan will close this four-part series about the fundamentals of gaming AI with a treatise on why AI in games is (still) not capable of sensible communication and natural behavior and why we probably wouldn’t even ever want that.