DEV Community

Cover image for The power of a good Artificial Intelligence.
Isabella Herman
Isabella Herman

Posted on

The power of a good Artificial Intelligence.

AIs are increasingly getting more presence in our daily lives. Virtual assistants who can tell you a joke, curiosities, can turn lamps on and lock the doors of your house or apartment to solutions in huge corporate companies.

In the 50s decade, we could watch the growth of AIs at games and see how it is a distinct ramification from the academics AIs. The main reason behind it is because the academical AIs are reflective of human conduct/behavior.

Human beings are not machines, we are made to live in society, chat with who we identify with. In this article I put away the idea of “opposites attract”. The player has to identify with the game world and a good AI will help you in this.

From the technical view of an AI for games, nothing is more than a lot of conditions: “if” here, “if” there. But if the conditions can be seen from a critical and psychological point of view, the game changes.


Good players do not want a good AI in their games. Players want experiences that can make them feel at power, or that they are good at something, feel rewarded with the victory. Human beings are not machines, we have reactions which must be explored by game design.

“Oh, but if the players do not like a difficult AI, why does Dark Souls have so much success?” The answer is easy. Dark Souls AI or the game are not difficult at all. They just work at a very rare soft skill nowadays: patience. Patience waiting to read and understand their steps from each agent of the game.
It is so simple, but since it is a real difficulty nowadays, the player feels the best of the whole world after scoring a victory in the combat.

Is it clear to understand the complexity and challenges? AI designs and applications must be sketched to stimulate a feeling of superiority and control, with the player confronting situations that balance the difficulty.

For example, you are producing a game set in WW2. In a scenery of war, it is completely normal to encounter armed enemies with different challenges settled in.
You idealized that in a mission where the player will have to stop the advance of an armored truck who is supplied to the enemy army. The truck has an X life and can explode with a player firing explosives at it, but how long will it take? The resistance of a bulletproof car is much more than the power of the armament of the player, this can cause an exhaustive experience over time.

With good AI we can find more interesting solutions. The truck is really strong but it is driven probably by an NPC (non-player character), so how can the player take this NPC’s attention away to stop the truck, get down and check what is going on, allowing a fairer combat and with a positive victory experience? The player can use smoke bombs, throw objects, use a flare gun among other events makes sense at the context.
The plain condition with eyes turned to the psychological aspect of the player originated a feeling of victory and superiority from him relating to the game. Understanding one’s emotional reactions that are connected with the game actions is essential.


A huge mistake in games when we talk about immersion, is to put a player as the only one to be alive at the game, which is not wrong in theory, but as game creators, we must be more skeptical with reality.

The GTA franchise has their importance and notoriety in the industry, they sell the idea of a universe with realistic experiences of an open world, which looks more like a driver simulator. You get to the car from point A to B and all the universe of the game stops, waiting for the player to finish what he is doing.
The experience of an open world where you are the center of attention and the main persona, does not work. The main character must be the center of attention of the player, not of the world.

So let's do an analogy from our life about how it would be represented in a game. Today you need to wake up and go to work, this is the most important task, your main quest. While you are getting ready to work, you start to experience heartburn, maybe it is because of the Mexican food you ate last night so you decide to go to a drugstore on your way to work. Different from going to work, you do not necessarily need to go to a drugstore, but it will be beneficial in something besides having a connection with some action of your day, so this is going to be your side quest.
Until then everything is very common in games, but life does not stop there. It does not stop because the world is so huge and there are a lot of people, variables, events, that must be considered if you have a proposal of an open world.

In Far Cry 4, there is an AI director who makes sure to make the universe alive. Considering the war tematics, it is safe to say that there are people needing help, not only in situations of kidnapping or invasions, but also in need of help to fix something that has broken, and their reality does not have any correlation with you, the player, who is just a newcomer from the army.

What is the sense of creating a random event like this in your mini map? Not a single one. But it is still there, because the universe of an open world game is and it must be bigger than the universe of the main character. Here is where the magic of the immersion from Far Cry 4 gives an entry. If you are wearing headphones it is possible to listen to NPCs calling you without a warning on the screen, asking if you can help, like it would happen in the real world.

The same example applies to GTA, it is common that as the game unrolls random people symbols will appear on the player’s minimap, who you can offer a ride to , even if they do not have any relation with the lore of the character.

But let's be honest, one of the biggest challenges for game developers it is to assemble a game system where the ‘open world’ can work, doing interesting and different events where the players can explore, and if along the years of franchise RockStar failed on this matter, they for sure have already redeemed themselves with the title Red Dead Redemption 2, where the AI act in the immersion of the world with mastery.

The comparison of Far Cry 4 and Grand Theft Auto V stops here, but let’s explore technically how the director AI commands all the territory from the game and it makes it look more alive.


First of all let’s understand the concept of Systemic AI, a systemic structure dependant of NPC’s: enemies, civilians, allies, animals, among others.
Each NPC quoted has their own comportamental structure and managing all of them together is not a simple or easy assignment, it is now that the director AI gives an entry.

A director AI whose name is very suggestive, like an organization director, controls the rhythm, the adequacy and each intensity from the events of the game.

The immersion of Far Cry 4 universe is without a doubt one of the best I have ever played, taking into account the time that the title was released and technical improvements since its ancestor Far Cry 3, which has been recognized by industry critics, scoring 85 on metacritic.
The director AI from Far Cry 4 monitors the players' steps accompanying the same one for a radius of 500 meters, and populates this radius with game events. Even with a limited radius, to populate this area with the entire systemic chain would be a huge computational cost really, so the director AI has to count with the rule: if the player doesn’t see, it can’t happen.

Adding to this general supervision, each NPC agent is commanded by a Finite State Machine (FSM), a mathematical model used to represent logical circuits that are very common in games, mainly for the necessity of low processment. Each agent’s FSM is projected to react to close stimuluses around the player.

diagrama de FSM

The diagram above was made to analyse carnivorous animal behavior inside of the game Far Cry 4. This topic represents each designed behavior to this circuit.

Next, we have the stimulus which triggers the FSM actions:

diagrama de FSM 2

The diagram’s initial components logic:

enum type {Prey, Predator}
enum agentBehaviour {Awake, Hunting, Eating, Patrolling, Recovering}

case agentBehaviour.Awake:
  if(type == type.Predator){

case agentBehaviour.Patrolling:
Enter fullscreen mode Exit fullscreen mode

Undoubtedly, for each of the explored cases there are N differente functions that must be analyzed to complete the logic in each one of the states. You can consider as an exercise to analyze the diagram and finish the remaining logic or even creating your own diagram analyzing the AI of a game that you like.

This is my first article and I hope that it showed you a different point of view of a subject that is getting more and more popular in the world.

Translated by Harianne Goya and João Corrêa.


MAUW, Sjouke. Finite state machine diagram of Protocol 3. Research Gate. March 1996.

CARRILLO, Richard. Interviewing For Game Design. GDC Session. 2017.

THOMPSON, Tommy. The Definition of [Artificial] Insanity: The Systemic AI of Far Cry. Informa, October 12, 2017.

SHUMMON MAASS, Laura. Artificial Intelligence in Video Games. Towards Data Science, July 01, 2019.

Davebot. Finite state-machine example. Undefined Games, April 24, 2019.

Far Cry 4 Review Page. Metacritic, November 18, 2014.

Top comments (2)

benjcodes profile image

Very interesting read! Great work Isabella!

isabellaherman profile image
Isabella Herman

Thank you so much!