The challenges of developing a sane AI enemy

Game Developer Teravision to become a flip-flop company
Teravision Games Pivots Into New Venture: Teravision Chanclas
April 1, 2021

One of the biggest challenges in developing AI for a game is that it needs to be so good that when you do things right, people won’t be sure you’ve done anything at all.

What is AI in a nutshell?

In one of our upcoming games, our base enemy is a little agent that by itself does nothing. Game AI is mostly focused on which action an enemy should take, based on the current conditions.

AI, short for artificial intelligence, in this instance, is the way information is taken from the game and translated over to our little robot enemies. They need to observe the game status and their surroundings, make a decision based on that information and then act upon the decision made.

The AI system weighs all possible actions with the game information inside a priority tree and decides where to go or what to do. After a decision is made, the AI creates a path and starts moving towards their goal. While moving they also need to check their surroundings, to avoid each other or dodge obstacles and keep checking the game status to react to changes in the game.

Simple, right?

Wait what’s a priority or decision tree?

A decision tree (sometimes called a priority tree or a behavior tree) is a way to organize the priorities and actions of a game’s AI agents – in our case, our little robot enemies. Selector nodes make the decision based on the AI’s current state and then prioritize branches to the left first.

Sequence nodes, in this case, are a way to set the order of actions (first go there, then search, then pick up item) and these sequences can be interrupted or canceled at any time by condition nodes or changes in the AI state.

Action nodes are then the final result of the whole decision tree and it tells our ‘lil robot what to do.

Here’s a good visual to picture how it works:

(source: https://www.researchgate.net/figure/A-behavior-tree-example-for-the-patrol-application_fig3_287209460)

That all sounds manageable – what are the big challenges for making an AI, then?

Have you ever tried to awkwardly get out of the way of someone and they move to avoid you, too, so you then keep awkwardly dancing to get out of each other’s way?

That’s called the crowd avoidance challenge – how and which enemies should move away from their path to dodge other enemies. That’s a fun one we’ve had to handle during the development of our most recent AAA-console game.

Another big challenge is constantly tweaking the system to make it feel like the enemies are communicating with each other. By design, our AI system works independently by enemy but this ended up feeling strange in gameplay. We upgraded our system to register how many enemies follow each target and adding it to the decision tree was quite the task to balance, time-wise. 

We had to do a lot of gameplay testing to get it right. We’re still not sure it works perfectly, but we’re keeping an eye on it.

What’s something most gamers don’t think about when they’re playing a game and fighting AI characters?

It’s all about how the game feels.

As a programmer, you are in control (most of the time) of all of the data in your game.

You can make enemies do whatever you want. They can know EVERYTHING about the player and the game world. There was a good example on Reddit – “Most fair AI ever,” with a great gif of how unbalanced an AI can feel to a player as a car drove backward and continued to beat the player despite all odds and how ridiculous the situation was.

The biggest challenge is remembering that the player’s feeling is the most important priority. The enemies must feel like a creature inside a world with limitations and mistakes.

Think about the grunts in Halo – if their Elite is killed, they may run away. That feels like something that would happen to a living, cowardly creature.

Leave a Reply

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