How enemy AI makes games special

Because AI can process information much faster than a human brain, it makes enemy AI a superb opponent in a video game. Monsters get constantly smarter. Wait a couple of years, and the antagonist of the game you play will easily beat us in IQ tests. On the other hand, that makes our time in video games more valuable.

So when does it all started?

Game enemy ai: From Pac-Man’s ghosts to Xenomorph 

The history of using artificial intelligence in enemy character development started long ago. 

Finite state machine technology allowing the non-player characters to react to what’s happening appropriately, building its behavior according to the conditions, has been used since the early stages of video game history. For example, ghosts in 80s’ superhit Pac-Man were probably scary enough for the ones who played at the time, though now they seem pretty predictable enemies. The ghosts were programmed to detect Pac-Man’s location, find him there and ambush him. Moreover, developers set all four enemies to bother the player in different ways. They seemed intelligent, as if a human played them.  


To make games with good enemy AI means to create an enemy that will have a human-like way of “thinking”. This will make them exciting to interact with and not too easy to demolish. 

However, usage of the concept “artificial intelligence” doesn’t necessarily make the character actually intelligent. There is a paradox: many AI enemies are far from clever. The example is not hard to find, if you, let’s say, tried to play Zoom 3. Remember those zombies? Ugh. We understand that they are creatures with damaged brains, but still, AI enemies are hardly supposed to get baffled by doors. Anyway, in many cases of AI usage this is far from impressive since the intelligent AI enemies are hard to make. But if it’s done as it should be, the result is spectacular. 

Perfect enemy AI in gaming 

The good game enemy AI combines masterfully created animation and a complicated set of conditions the character is programmed to meet. Actually, the quality of AI in a game is usually defined by the number of conditions the character can behave according to. The antagonist is supposed to consider the place where the player is located, the actions they do, and, if possible, the actions they are going to take. 

The level of enemy AI intelligence may be defined by the number of conditions it meets. The very primitive set of conditions for a game monster may be determined like “If the player is around, attack them with a sword you have in your hands”. More complex set of tasks may include finding where the player is, chasing them, defending against their possible attacks, predicting the actions the player may do at certain points, cooperating with other NPCs etc. And surely not be confused if something does not go as planned. The smart enemy is programmed to consider all (or almost all) possible “what if “s. 

There are a number of AI instruments usually used in NPC development. Pathfinding is the technology which instructs the character on where they can go in the game environment. Behavior trees are the sets of nodes defining the NPC’s decision-making in different situations. 

Automated planning is setting a plan for a character that must be achieved by completing specific sequences of actions. The NPCs are programmed to “learn” information about their given circumstances at a certain point in a game. The character is programmed to “understand” the current set up and the effects of how the situation will change after they make an action. 

For instance, at a particular point in a game, the enemy has a task: to attack a player. For this, they need, let’s say, to pick up the armor from the ground. These actions are getting encoded as the problems the NPC will face and how to solve them. For example, all the NPCs in FEAR have goals to achieve throughout the game, and the planning is made to let them accomplish these goals. The database editors were used to set actions for particular characters. 

Variety of foes

Gameplay: Aztez

The enemy AI in the video game may be individual, but also it may be group AI controlling all of them. The attacks of enemies should always be systematic and under control in order to avoid the chaos which can occur when a number of foes attack the player simultaneously. If that happens, the player has to be given enough mechanisms to resist the attacks, as, for example, in one of the best beat-em-up indie AI combat games Aztez

The AI enemies are often divided into near and far groups. The members of the near one threaten the player at the moment, so the player needs to pay the most attention to dealing with them. The ones from the far category are usually idling and waiting to join the near group. 

Besides attacking, the AI enemies are able to chase the player, and defend themselves against the player’s attacks, using counter-attacks, dodging or blocking. 

Also enemies may be aware of what their comrades are doing to plan their attacks on the player in the most clever ways. 

However, another important point is that the enemy AI should not be too smart. 

The game creators are not interested in using the full potential of artificial intelligence in enemy AI characters’ development because the too-hard-to-beat enemy will be nothing but frustration. What’s the point of playing the game if you can’t manage to defeat the bad guys? 

That’s why the game enemy AI characters usually use a “tell” sign warning the player that they are going to attack right now. This allows the player to react properly: after receiving the warning, the player can get ready to block the attack, and avoid or confront it.

The big goal of AI usage in game development is to make enemies and NPCs, in general, more alive and real, giving them human ways of reaction, teaching them to develop dreams, feelings, etc. Although there is a dilemma about this: in that case, won’t playing video games become too similar to real life? In many cases, unrealistic actions of NPCs is a factor that makes video games a feast of escapism. So, while making NPCs more intelligent, the devs should not let them spoil that magic where the player may feel and act as a powerful king of an extraordinary fairytale-like world. The enemies are not supposed to react as real humans in similar circumstances would do. 

Let’s analyze a few good AI enemy examples 

Image: The Last of Us Part 2. Naughty Dog

The good AI enemies are shown in The Last of Us Part 2.

The protagonists, Ellie and Abbie, are facing foes divided into two categories: infected and humans. The set of conditions the enemies fulfill there is impressive.

The enemies cooperate and reach for each other’s help. They are programmed to demonstrate emotional bonds, for example, when they mourn their dead friends. What is also crucial about The Last of Us 2 is that the gamer really has hard time trying to predict how the enemies will behave in particular situations. When the human enemies see the bodies of their friends killed by Ellie or Abbie, they will definitely try to get revenge. It’s not easy to kill the enemies without endangering yourself, as there is always a possibility of being stealthed by the defeated foes’ friends. 

And it’s hard to hide from them since they are programmed to react to the smallest signs of the protagonists’ presence, such as for example, the flashlight. 

At the same time, they are not too smart because it is possible to play tricks on them. For example, if caught between the groups of infected and human enemies, the player may drop a bomb into the human group, which will probably distract the infected, tricking the groups into fighting each other, and leaving the protagonist a way to sneak out. These enemies, therefore, are smart but not unbeatable ones. 

Mind-reading: the best AI enemies’ feature 

The best AI enemies existing so far are the ones capable of reading the player’s mind. 

But don’t worry; it’s not the sign of a cybernetic apocalypse coming soon — just masterful game development with a combination of different AI technologies applied. A good example is Xenomorph in Alien: Isolation — one of the top most brutal enemy AI in games. 

When Xenomorph is chasing you, guessing your every move, isn’t it terrifying? You never know where it’s hiding, you feel non-stop suspense, knowing it follows every step you made. 

What’s also meaningful is that the Xenomorph AI allows it to adapt to the gamer’s playing style. Its creation is the combination of Director AI and Behavior tree technologies. The first one allows the monster to be always aware of where the player is and what they are doing at the moment, while the second one rules Xenomorph’s actions. 

The unkillable monster can hear you, smell you, see the weapons in your hands (this will make him change his tactics), and even capture you moving behind its back — thanks to his back-head eyes. 

Xenomorph’s AI also counts the encounters the player has had with the monster in order to predict how much stress the player may feel at the moment, just to not overwhelm them because it’s all about the balance between suspense and relaxation. This is used to protect the player from getting exhausted and the game from becoming too complicated and, therefore, frustrating. 

Xenomorph can also gradually grow stamina for the pain after getting blasted with a flamethrower many times. 

Also, it’s not only concentrated on ambushing the protagonist, it loves to take time to check out the items in the environment. The ability to get curious is another feature of human-like intelligence, so good monsters may show curiosity. 

How to check if the monster you created is really smart? 

Try to beat them and be ready to lose. 

Interacting with Xenomorph is complicated not only for players, but for the developers of Alien: Isolation as well. They had a lot of hardships encountering the monster while testing the game. 

Would like to create smart enemy AI monsters on your own?

Image: Will You Snail

The enemy AI development is available not only for big companies but for everyone interested. For example, in 2022’s indie game Will You Snail, the evil AI literally blows players’ minds by predicting their every move. The game was made pretty quickly by only one person. 

Developing enemy AI from scratch is easy now. For example, you can learn how to do it on Unity platform. Just check out the tutorial made by the guy from Magic Pig Games, read the instructions on Medium, or just google it and find all kinds of useful information. 

The conclusion is simple: the AI enemies could make some experiences truly special. The video game enemy should wittily react to every decision made by the player, behaving appropriately in every situation. When the player not only overcomes simple obstacles but confronts the highly intelligent enemy, it means that the game is really immersive and exciting. And that’s why smart monsters are the best. 

Author: Vira Duzhak