📜 ⬆️ ⬇️

Cyberdemona: artificial intelligence DOOM 2016

Over the years, first-person shooters have evolved and become a very interesting environment for non-player characters: soldiers hide behind cover, strangers are chasing the player, and teammates help him in the heat of battle. All this fits into the design concept of modern shooters: holding territory, creating lines of defense and deterring the player. In this article, using the example of restarting the DOOM 2016 franchise, I will talk about what happens when developers refuse to use a standard code of conduct in the game.


DOOM is built on a philosophy known as push forward combat , which influences narrative, level design, player movement, and more. In short, it is a critical eye and a reaction to modern shooters. While Call of Duty forces the player to crawl behind cover and shoot enemies from afar, DOOM breaks these rules by creating a powerful, fast, “spinal” gameplay. But how does all this work, and what does the AI ​​do to make the gameplay alive?

Aggressive fight


The Push Forward Combat philosophy covers all aspects of DOOM : it defines the foundation of the game and how players interact with the AI ​​in combat. As Kurt Laudi explained in his report at GDC 2018 , the game heavily borrows the mechanics of the original DOOM games: fast motion, hidden corridors and violent gunfights. But although she seeks to return to the roots, at the same time she needs to attract a completely new audience who have never played old school FPS, including DOOM with DOOM II: Hell on Earth . Therefore, an aggressive battle is built on four pillars, on which stands the design of the whole game:


These four pillars allowed the creation and improvement of the mechanics of the game; thanks to them, it became obvious which of the mechanics strengthened the principle of aggressive combat, and which of them interfered with it. Therefore, the reloading of weapons was removed from the game, because it interfered with the flow of the battle, and a double jump was added, allowing you to quickly reach the enemies. Finally, the basic gameplay must be intuitive and interesting, but at the same time it can become more and more complex, rewarding the player for the right choice of targets and weapons. DOOM fights often take place in medium and large arenas, asymmetrical in nature, with many vertical movements. They are much closer to multiplayer online shooters than to traditional single-player campaigns. Add enemy demons to your line-up, and you’ll get what id calls “battle chess”: the player’s task is to find out which demon to destroy first, and how best to reach him.
')

To implement and hone this gameplay will require a set of new tools. The AI ​​systems used in it are created under the serious influence of more traditional first-person shooters and are adapted to the DOOM concept. I will come back to exactly how AI DOOM, thanks to its structure, reinforces the concept of Push Forward Combat, but first I would like to explore the work of AI architectures and explore the sources of its origin. To do this, we first need to talk about DOOM , which has never been, and how it turned into a 2016 game.

DOOM rescue


It is well known that the development cycle of DOOM 2016 was difficult: the franchise had problems of identity and did not know what it would become in the modern era. Initially, the game resembled more modern shooters, but in the end it was scrapped, and from that moment began to take the form of the DOOM that we know today. It was during this transition that it turned out which tools of the AI ​​AI can be adapted to the game and how they can help implement the concept of aggressive combat.

DOOM 4 - as it was originally called - has been in development since 2008. The parent company ZeniMax Media, which bought id Software in 2009, was unhappy with the development process and, after an internal audit, in 2011 insisted on changes. Sources close to the project, who wished to remain anonymous, informed me that the Rage development team, which was preparing for the beginning of the sequel's preproduction, had to stop working and merge with the DOOM 4 team. “Call of Doomy,” as the game was scornfully called in the studio, dramatically changed course, changing from DOOM 4 to just DOOM . This led to serious disappointment - ideas and personalities opposed the new direction chosen. The new design of the project led Matt Hooper to begin the search necessary for the revival of the energy of the classic DOOM . My sources claim that the success of the Brutal DOOM mod by SgtMarkIV has become something of a confirmation of the validity of this ideal. This led to the creation of a new gameplay demo, released in 2012, which focused on the philosophy of push forward combat, and also reworked the glory kill system (approx. Lane: an effective system for hitting the enemy in melee) already present in DOOM 4 .

Together with a lot of experienced developers who have moved from the Rage team to the creation of DOOM , a lot of tools and systems were transferred to the project from the game itself and from id Tech 5. Let's talk about the basic tools of the AI ​​architecture in the id Tech engine, as well as how these systems were created and polished under Rage were later ported to DOOM .

AI Architecture


The development of the toolchain AI as part of the id Tech 5 engine began in 2005, almost immediately after the release of DOOM 3 . It was first tested in the Rage case. The main decision-making system of enemy AI in Rage and DOOM consists of hierarchical finite state machines (Hierarchical Finite State Machines): a variation of the classical implementation of AI, providing increased flexibility and control over the sequence of states with their behavior.

Hierarchical finite automata


Finite state machines (Finite State Machines) are closely related to the state principle, during which the AI ​​can perform certain behaviors. Also, if certain conditions are met, the AI ​​may move to other states. Connecting the set of states into groups and implementing transitions between them allows you to create flexible, responsive and interesting behaviors. One of my first videos about Batman: Arkham Asylum tells how they were used for stealth and fights.


However, the scheme can quickly become very complex: the number of states increases, and the number of transitions between them becomes even greater. To cope with this problem, hierarchical finite automata (IKA) group certain sets of states and perform them in one cluster with clear transitions in and out of this cluster.


In essence, clusters create small finite automata inside a large finite automaton into which and from which the system can perform the transition. This allows you to create a more ordered and structured behavior in which the individual states are present in one or more groups. Because of this, specific aspects — moving to cover, attack from a distance, or approach — can be processed and modeled for each daemon.


This distinguishes DOOM from many modern shooters, in which finite automata are much less common and Behavior Trees or even HTN planning become popular.

The ICA system in Rage allowed designers with a certain flexibility to customize behavior in specific situations, but only programmers could create such state machines. As my sources told, the best thing was to give the design team a large set of interesting and exciting behaviors for each battle. This made it possible to preserve the integrity of AI systems and minimize the likelihood of their failure or unexpected behavior. To ensure the integrity of the entire process, DOOM state machines can only be created using a specially created editor that has an interface with C ++ code that was used to build individual states. This editor has become an enhanced version of the previously created macro language for Rage , which is used in the editor to record the states and proposed transitions of the new finite state machine. It performs cross-references with C ++ header files that define all possible transitions for the current state. This turned out to be an incredibly valuable feature for a team of programmers, because it allowed us to quickly check the integrity and structure of the entire state machine, either manually or using the graph visualization tool. The finished implementation was quick and did not require managing a huge amount of resources in the game. However, despite the fact that the created tools provided a clear visualization of the structure and behavior of finite automata, they also increased the number of abstractions, which complicated the step-by-step execution and debugging.

In addition to the ICA used to make decisions about the actions of the demons, DOOM uses two systems created for Rage : the shelter system and the animation system.

Animation system


The animation system called AnimWeb itself is also a state machine. Each state controls the execution of an animation for a particular behavior, and state transitions control the mixing between animations. The system often calculates paths using AnimWeb, which triggers initial, intermediate, and final animations for specific AI states with transitions synchronized with specified mixing points, calculated from bone analysis in the skeletal mesh. Why this system is vital, I will tell in the analysis of the design behavior of demons. We learn what AnimWeb does to tweak and change the animation at runtime, so that the demons frighten the player throughout the gameplay.

Shelter system


Finally, a hiding system was created and tested in Rage , actively interacting with decision-making AI, AnimWeb and built-in navigation tools. The Rage combat system, and therefore its shelter system, was inspired by early Halo games, in which monster squads sought in areas with good shelters, while heavy enemies, such as Shrouded and Gearhead, attacked the player in open space. This system took into account the distance between the player and the available designers, defense positions, AI positions relative to areas of good shelter, visibility of AI opponents for the player, presence in the shelter of friendly AI, optimal positions for throwing grenades and much more. You are probably wondering why this is so important: the AI ​​in DOOM never hides behind cover, and the cover itself, in general, violates the concept of aggressive combat. As I will explain below, this system is incredibly important for positioning demons in DOOM , but in a completely unexpected way!

The development and production process of Rage made it possible to bring all these AI systems to maturity and use them in other products. They not only migrated to DOOM 2016 - which uses the id Tech 6 engine - but are also used in the 2014 Wolfenstein: The New Order game by MachineGame. Although these systems have already proven their worth, they needed further tweaks and improvements for use in DOOM . In addition, the designers had to make the behavior of the system in the context of an aggressive battle. Therefore, let's find out about the designer secrets that made it possible to realize this philosophy.

AI design


Now that we know about the internal AI systems, let's see how they are used to create enemies in DOOM and reinforce the core of the design. Therefore, let us return to the four game pillars of the aggressive battle: the speed, the individuality of the demons, the uniqueness of the weapon and the power of the player. What does AI do to enhance these aspects?

Speed


To begin with, let's talk about speed: a player can move around the world very quickly, and the AI ​​takes this into account in two vital ways: shooting and enemy location. The accuracy of demons is intentionally reduced depending on the speed of the player: the faster he is, the harder it is to get into it. This is achieved through a weighted distribution of accuracy of shots - the demons deliberately miss when the player moves at maximum speed, and become more accurate when he slows down. In addition, this system is associated with levels of complexity: with high complexity, the accuracy of the demons more quickly compensates for player movements. And one more touch: the enemies do not shoot at exploding barrels, even if they are near the player, in order to give the player a chance to use them against demons.


However, the AI ​​positioning system in combat is even more interesting in order to maintain its effectiveness and ensure the player’s freedom of movement. Shooting enemies, such as imps, kakodemons and mankubusy, actively seek, if possible, to be at a distance from the player to attack from afar. At the same time, the game seeks to ensure that other enemies are well placed to attack, given that they will need to flee to the player at any given time. To achieve this, DOOM takes the shelter system from Rage and inverts it : the system is used not to find shelter points, but to find open positions next to the shelters that provide maximum visibility for the player. Such "inverted" cover not only allows the demons to continue to attack, but also helps the player to find the target.

Individuality


Now let's consider the individuality of demons. There are 16 separate AI archetypes in DOOM , each of which has unique behaviors and animations that highlight its characteristic features. Given the high pace of the game, the main goal is to instantly recognize the demons by the player and ensure the integrity of their behavior. Imagine Pac-Man , in which the player moves 10 times faster than usual, and ghosts are in fact hellish hordes! There is simply no place for intricate and complex behavior. Opponents should be recognizable for the player and interesting for the designer, throwing them on the chessboard of battle.

This goal is achieved not only with the help of exaggerated animations of behaviors, but also through the goals of the enemies and the ways of achieving them. Almost as in the classic DOOM , many of the AIs have their own recognizable behaviors, but adapted to the design of the modern DOOM : pink demons rush to the player, trying to ram it, and keep the imps away to throw fireballs.

In addition, the animations are created in such a way as to emphasize the specificity of each demon archetype. In addition to implementing smooth blending, AnimWeb also performs real-time animation checks to make sure the animation can fit into the demon’s motion curve. Therefore, imps can jump over short and long distances using the same animation, which is adjusted in real time, and the knights of hell perform checks so that they do not intersect with surrounding objects during attacks. In addition, each daemon performs a process called Focus Tracking: it calculates a suitable turn of the head, chest, and hips in the IK-riga to turn around and look at the player in the right way.

In addition to all this, DOOM again returns the quarrels between enemies that were used in the original games of the series: the faction system captures the interactions and behaviors between the individual AI archetypes. She uses a system of rules that determines how and why one faction of demons begins to get angry at another. In addition, it captures such events as accidental or intentional damage inflicted by such fractions on each other, and uses them to launch battles between enemies. The factions inside the system borrow the habits of other factions , so while the imps suffer from the paws of mankubus and barons, the obsessed UAC soldiers are equally hated by all the demons and are usually killed first in internal quarrels.

Uniqueness


Now let's talk about the uniqueness of each weapon. AI DOOM reacts when a player uses a suitable weapon for a suitable demon. This is mainly implemented by a continuous damage per second system and a battlefield condition management system. She makes the demons vulnerable to shots from a specific weapon, and they fear these weapons. My sources explained that inside DOOM a system of long-term DPS (damage per second) is used, rewarding the player for prolonged aggression towards a particular demon. Damage becomes prolonged, which triggers the demon's pain response. Jake Campbell talked about this in his report at GDC. These pain reactions can be very diverse: from small convulsions, which slightly affect the accuracy of the AI ​​sight, to fading and retreat, interrupting the current behavior of the AI.


To further reinforce this system, certain types of weapons trigger reactions in different types of enemies. For example, when firing an assault rifle, the imp stops moving, and the zombies, when fired from a shotgun, quickly turn into a staggering state in which they are easy to kill. My sources said that at the design stage, the Kakodone could get stuck in a constant fade reaction during continuous minigun shooting. This was deliberately done to salute the original DOOM, but it was abandoned before the release of the game.

Player power


Finally, despite the innumerable hordes of demons and the danger posed by them, the concept of aggressive combat should always strive to empower the player with power. Therefore, the game must maintain the balance and rhythm of the battle, ensuring the player is always in the stream. For this, DOOM uses a combat system that forces demons to ask permission to attack a player . This is implemented through a system of tokens: each type of attack — hand-to-hand, long-range, and so on — has a limited number of tokens at each time instant. To commit an attack, the daemon must request a token, and after use return it to the system. Each difficulty level has its own set of token values ​​for each type of attack, creating a more aggressive horde of demons and at the same time maintaining balance due to the restriction on the number of simultaneously attacking demons. The funny thing about this system is that demons can steal tokens from each other if they feel that ways to use them more efficiently at the current time. The main reason for this is to force the demons next to the player to attack him, and not to stand next to a stupid look.


In addition, the designers realized that it would not be fair if the demons would attack when the player could not respond. Therefore, during the execution of glory kills, the player is invulnerable, and artificial intelligence has no right to start a new attack behavior until the glory kill is completed. Finally, glory kills are valuable to the player in that they give health, and in the case of a chainsaw kill, ammunition! When glory kills players always drop items, and big demons give even more life. However, the drop-down ammunition is basically constant, because the game wants the player to continue to master his arsenal and use the best weapon in the current environment. Therefore, if you use a chainsaw to kill a knight of hell, this will not give you more ammunition as a result!

Finally


The return of DOOM in 2016 turned out to be triumphant, but as we have just seen, it was not accidental: thanks to the years of work on the game AI, the demons of hell rebelled in full force. This game is a clear example of the use of classic AI techniques along with design tools that reinforce the core of the gameplay. Like the entire franchise as a whole, DOOM states that although some AI creation tools are already out of fashion, there is still the potential to create an interesting new gameplay that will attract and modern players. While this article was being written, it was announced that DOOM Eternal was being developed with even more demons' archetypes. Hell on earth has never been so exciting.


Bibliography


Loudy, K. and Campbell, J. 2018. Embracing Push Forward Combat in DOOM. Game Developers Conference, 2018.

Cambell, J. 2017 Bringing Hell to Life: AI and Fully Body Animation in DOOM. Game Developers Conference, 2017.

Source: https://habr.com/ru/post/419537/


All Articles