The Artificial Intelligence of Doom
Doom's artificial intelligence

Doom. We've previously explained how to get ithow to get it, how to play it with ray tracing, and how to run it on strange devices like a landline phone. We've also taken a close look at its most insane speedrun and the origin of its sounds, but I must admit we never explored its artificial intelligence... until now. The YouTube channel AI and Games published an excellent mini documentary about Doom's artificial intelligence, covering its main features, enemy behavior, and more.

Search any list of the best DOS games, and you'll see Doom comfortably in the Top 10. If you decide to explore DOSBox territory on modern systems, Doom is one of the first games you should try, or alternatively you can download some of its source ports. And if you enjoy electronics or hacking certain devices, Doom has become the Hello World par excellence.

However, there is still much to learn about Doom, starting with its artificial intelligence. You might remember details like enemies with their backs turned at the start of a level, or more "colorful" deaths in terms of blood and guts. All of that has a mechanism behind it, and the YouTube channel called AI and Games explains it in a mini documentary that doesn't exceed 30 minutes.

How Doom's artificial intelligence works

The artificial intelligence of the enemies is actually a class of object inside the game called Thinker or Thinker. Doom has a total of four thinkers: Actors (player, NPCs, the levels themselves), the status bar (which constantly calculates new values), the map (with its corresponding updates), and the HUD rendering. The core logic of the enemies is what is defined as a Finite-State Machine, a resource to make characters execute certain behaviors under a defined state.

The Artificial Intelligence of Doom
The eight 'modes' or 'states' in Doom and Doom 2

The Finite-State Machine uses a diagram of eight states or nodes. Enemies always start under Spawn, a state in which they basically wait for an event or stimulus. Do you remember the enemies standing still with their backs at the start of Doom II? That's Spawn. Then they move to See, which allows them to move and head toward their target. Depending on the situation, the enemy can adopt two types of attack, Melee or Range, returning to See when the attack ends. Pain is the pain state, which only happens when the player causes damage, but it doesn't activate in all cases; it's based on a probability coded into each enemy's design.

The Artificial Intelligence of Doom
The gib is not random: It depends on a special calculation

Finally, Doom's enemies have two types of deaths: Die is the conventional type, which occurs when the total damage received exceeds the base health. But there is also XDie for the gib effect, that is, when the enemy receives so much damage that it is reduced to pulp. For the gib to happen, the damage at the moment of death must exceed the remaining health value plus the original health. Example: An Imp has 60 health points. If we attack it until it has 10 points left, to trigger the gib effect we need to cause (10+1) + 60 = 71 points of damage. Technically, any enemy can be gibbed, even bosses, as long as a telefrag is involved, which causes 10,000 points of damage.

The last state is Raise, linked to the Arch-vile from Doom 2... but you'll have to watch the rest of the documentary to understand how it works. If you're a Doom fan, you can't miss it, and if for some reason you don't like the franchise but are interested in the technical profile of classic games, I'm sure you'll find useful information.