Game AI: The tricks designers use to make non-player characters seem real

In their raw state, game AI characters would be robotic and almost impossible to beat in combat. Here’s how designers make NPCs and enemies seem more human.


From octoroks in The Legend of Zelda to enemies in Call of Duty, odds are that if you’ve played a video game you’ve encountered artificial intelligence – whether you’ve realised it or not.

Game AI can take many forms, but generally speaking it’s any entity that has a sense of awareness or knowledge of the world around it, and can act or react to it accordingly.

There’s a tendency among players to think of AI as just ‘organic’ things in the world, like humans or animals, but the reality is that AI can be anything that acts with awareness of the world around it – it doesn’t even have to be organic! For example, a turret in a level that shoots at someone in its area of influence is an AI (since it is reacting to a target’s presence in the world). A human NPC in a world might not even necessarily be an AI if they just stand in one spot and don’t actually take any action or process information about the space around them, in which case they’re just like any other game element.

This distinction matters because anything that exhibits this sort of reactionary awareness usually needs to be tamped down to maintain a fair level of challenge. At a baseline, a game engine controlling the AI will always have all the information about the game – where the player is, what they’re doing, how fast they’re moving, where they are relative to the AI, and so on. The player, on the other hand, only really knows what they can see and hear from their perspective. Therefore the AI easily has the ability to go Terminator mode and beat the player with expert tenacity since they can read all the factors of a situation. 

It’s similar to if you were playing a game of Counter Strike where every member of the enemy team was using an aimbot – it would be almost impossible to win unless you’re incredibly lucky (or have thousands of hours in CS:GO) because everyone knows exactly where you are and where to aim. This is why much of the work of AI designers is mostly limiting what information an AI has and is able to use at any given time, which allows them to control their efficiency in performing their task to give players a fair challenge.

game ai

Ashley Graham from the Resident Evil 4 Remake is an excellent example of an AI. Her simple behaviour is given the illusion of life through attention to detail in her animation and dialogue. Credit: Capcom.

It’s a fine balance to be sure, and a lot of the work is ensuring that the appropriate level of “fairness” is achieved. AI that has too few limitations can be too smart and be too difficult for a player to overcome, while AI with too many limitations might be seen as too confused and easy to defeat.

Warning shots

To counter the fact that AI are operating with different information than players have, designers often use little tricks to help stop the AI from overwhelming the player. One such trick in shooters, where players have a limited directional field of view, is that enemies who are out of view for the player are given a much greater chance of missing their shots when the player isn’t looking at them. This makes their bullets act more as warnings for the player, and gives them the opportunity to notice their presence and engage the threat before unfairly catching them off-guard. AI are also forcibly given limited scope of vision that are constrained to a specific area around them, which allows a player to see an AI and prepare to encounter them accordingly while still remaining unseen to the AI. 

Similarly, in action games where players are fighting multiple enemies at once, many games will have unseen coordination systems running behind the scenes during a battle that help determine the level of challenge. For example, instead of having every active enemy attack the player at the same time and create a no-win situation, the engine will establish a plan of attack – one or two enemies are chosen to lead, which paces the battle out more slowly and saves the player from having to juggle too many combatants all at once.

In real life, if you’re fighting ten people at once they’ll probably just gang up on you and kick your butt. But the point of AI design isn’t to replicate real life, it’s to create an appropriate level of challenge. It might not be exactly how a player expects a real-life counterpart to act, but in many cases, if AI performed just like its real-life counterparts then the game would be far too hard because it’s so intelligent – most players wouldn’t have fun at all. For many players, fighting AI who are smarter and more well-equipped than you ends up being more frustrating than it is fun, and sometimes it takes a little bit of cheating on the developer side to make it an engaging experience.

Masking behaviours

Another overlooked part of AI design is ‘masking’ AI behaviours to appear less logical and robotic, which in turn helps to add to the game world’s immersion. Since an AI is operating based on computer-driven parameters, the actions they perform tend to be exact and rigid: they might shoot perfectly in a straight line, have very obvious transitions between one behaviour and another, or walk unwaveringly between two points while patrolling. This can make them feel too much like computer programs and not enough like fallible creatures living in a real world. This is where other disciplines like animations, feedback and effects are added to make an AI feel more organic and less machine-like; behaviours such as taunts, speaking to other AI, or pausing to perform some mundane action can help make them feel more like a real organic creature reacting to stimuli in the environment, even if they have little effect on their in-game competency.

game ai

In most games, AI move using a grid called a “Navigation Mesh” which follows terrain and tells them what assets they can and can’t walk on.

A wolf howling before attacking the player is an example of this – it doesn’t need to howl to complete its task of attacking the player, but without that element it’s going to feel less like a wolf and more like a direct killing machine. A little bit of inefficiency is added to combat it and make it feel grounded in reality.

In fact, one of my favourite techniques for AI in action games is the way that groups of enemy AI communicate with each other, which informs the player what the engine is doing behind the scenes. When a player hears one enemy call out a line of dialogue to another – something like “I’m going to flank them!” for example – the assumption is that this dialogue is what the game is using to tell an enemy to perform a flank. However, in many cases what’s actually happening is that the game has already decided to carry out the action. Since it’s a simple computation, the line of dialogue isn’t necessary for the game to tell an AI to execute the action, but rather the dialogue is there to inform the player that an AI is carrying out an action, and is warning them to prepare to adapt to the situation.

It’s sort of like how an enemy will shout “Throwing grenade!”, when they’re throwing a grenade. Even though that isn’t necessary at a computational level or a realistic one, it’s vital player feedback to level the playing field and give the player a chance to prepare for the action to be executed so they’re not suddenly overwhelmed when a grenade lands at their feet.

As it turns out, there’s a lot of work in making a computer not feel like a computer, and AI designers really have their work cut out for them. As game worlds get more and more real, these sorts of AI design tricks are only going to get even more important to help balance AI in ways that hit the sweet spot of realism and practicality, while still creating challenges that are fair but fun for players.

Leave a Reply

Your email address will not be published. Required fields are marked *

More like this