Featured Blog | This community-written post highlights the best of what the game industry has to offer. Read more like it on the Game Developer Blogs or learn how to Submit Your Own Blog Post
7 Ways to Make Your AI Smarter
7 Ways to make your AI appear smarter in action games without breaking the bank with middleware or expensive code rewrites.
halflife2351
Prompted by this article over at Bit-Tech on How AI in Games works it made me want to blog about some of the ways you can make your enemy AI appear smarter without having to re-write your AI back end or invest in expensive middleware.SCRIPTING
A huge amount of what convinces us a game has good AI is often completely scripted. Nothing ruins the illusion of AI like the Level Designers treating them purely like cardboard cutouts or filler. What the AI is doing before they start fighting is just as important as what happens during the fight.
My favorite reference for believable AI scripting are the No-One Lives Forever games. Yes you couldn't go more than ten yards without stumbling on a pair of AI guards having a conversation but it adds so much to their characters that you become far more forgiving towards them.
The arrival of an enemy is a great opportunity to make them seem smarter than they really are. AI that Rapel down a wall before fighting you or who shout for backup when they see you causing two more enemies to sprint around the corner. These are almost always scripted events but most Players will attribute it all to the AI.
Even just adding Patrol routes or some good ambient animations can make a very simple AI character appear more inteligent.
FEEDBACK
AI that don't tell the Player what they are going to do before they do it look stupid.
In Half Life the Soldiers would always shout "GRENADE!" before they threw a Grenade at you. When they shouted "Flank Left!" an AI would always run out of cover moments later.
You are making your enemies appear as if they have goals and that they are trying to fulfill them. If the player doesn't know what the AI was trying to do then alot of their actions won't make any sense. If a Soldier just ran out of cover then the Player would assume the AI is stupid for leaving cover. By preceeding it with the command "Flank Left!" the enemies behavior is given a context that makes a stupid suicidal manouvre appear inteligent. Your enemies don't have to actually Flank anybody. They just need to say that they are before they move somewhere else. The Player will assume the AI is trying to do something very clever when they are really doing something immensely stupid. It's all about context.
Above all else AI that are talking to each other and the player appear more Human. The Grunts in Halo would have seemed very stupid if they had never said anything. Instead you always knew what was going through their tiny minds as a result of your actions.
ACCURACY
If your enemies carry guns then don't turn them into Storm Troopers (unless they ARE Storm Troopers in which case it's OK). While the Player should have an advantage ov er the AI in terms of accuracy making the AI too inaccurate will just result in them looking stupid. If the player realises that they can just stand still in the open while they pick off the bad guys with a single headshot each then their sense of immersion will be completely broken.
Below is a video I made when we were making Wheelman to indicate just how "Stupid" AI can appear when they are inaccurate. The good stuff is at about 1:50.
Playing Half Life 2 Unsympathetically (YouTube)
If you want your AI to miss then put some effort into making them miss believably. If they are using automatic weapons then have them group their shots in a burst and have the entire burst miss. Don't just spread the shots out in a cone around the player because it's much more noticable.
If the Player is standing still in the open looking at the enemy then the AI should tear the Player a new one.
LIFETIME
You can have the most inteligent goal-oriented perfect-pathfinding AI enemies in the world but it doesn't count for anything if the Player is killing them before they get to do any of that clever stuff.
The biggest difference in Halo between the AI in Easy mode and Legendary mode is that in legendary the AI has more health. This meant they lived longer and as a result did more cool clever things making them appear more inteligent. They were also more accurate and did more damage which supports my previous point.
Adding health isn't the only way to increase your AI's Lifetime (and you may not be able to get away with it contextually) but there are other ways to make your enemies live longer.
Enemies that can Blind-Fire are harder to kill while still presenting a threat to the Player.
Make the Players weapons less accurate meaning they have to work harder. Too much aim-assist is a bad thing.
Allow enemies to break-out of Hit-Reactions quickly. If your Hit-Reactions are too long then you often only need to land one hit to neutralise the enemy. The remaining hits are a formality.
More Enemies at once mean that even though Individuals die quickly the others are showing off in the meantime.
ROBUST
If I had to choose between Very Clever buggy AI and Very Simple Bug-Free AI I will always pick the Simpler choice.
Every time an AI gets a Path wrong or does something slightly unpredictable (in a bad way) is another notch against your AI appearing smart.
Half Life 2's Combine AI is really simple but also very effective. Their basic behavior is to move towards their target shooting at them if they have line of sight. When they need to Reload they will move to a position where they can break line of sight.
That's roughly 80% of the Combine AI right there. It's incredibly simple and copes with just about anything you can throw at it. Because it's so robust it rarely goes horribly wrong and the Player can build a mental model of that enemies behavior very quickly that is always right.
When the AI behaves how the Player predicts then the AI is perceived as being smart because they have fulfilled the Players expectations of them. When the AI exceeds these expectations it's even better. However the most important part to nail first is that the AI never falls short of them.
MANAGE EXPECTATIONS
Human shaped AI are the hardest to get right because as Humans we have very high expectations of their behaviour. We interact with other Humans everyday so Human AI in games needs to fit into an existing Mental Model informed by our life experiences, TV, Films and all sorts of other crap.
Aliens, Animals, Robots. All of these are far easier to make appear inteligent because our Expectations of their behaviour aren't preconceived or at worst much lower. Nobody knows how a Strider is supposed to act before they start fighting one. You can infer a bit from the way they look and move but they are essentially a blank slate. A Strider can behave however Valve wants them to and so long as they are Robust they will appear inteligent.
If Halo's Grunts had been Human shaped then their AI wouldn't have seemed as clever as they wouldn't have matched our preconceived expectations of how Humans behave. Don't underestimate just how much leeway using non-Humans will buy you.
LEVEL DESIGN
Bad Level Design can make good AI look terrible. It is the job of the Level Designers and AI Programmers to ensure that everything in the game is working together to create the best experience possible. If you spend six months crafting cautious cover using AI and all the Levels in your game are empty warehouse deathmatch levels then your AI isn't going to look good.
Make sure that Levels are playing to the AI's strengths and vice-versa.
The above article was originally published on http://www.agamesdesignblog.com on March 9th 2009.
Read more about:
Featured BlogsAbout the Author
You May Also Like