Heart of Darkness | Behind the AI and Storytelling of Spec Ops: The Line

July 9, 2018
protect
<iframe title="Behind the AI and Storytelling of Spec Ops: The Line | AI and Games #29" src="//www.youtube.com/embed/Y--BgBOPduE?enablejsapi=1&amp;origin=https%3A%2F%2Fwww.gamedeveloper.com" height="360px" width="100%" data-testid="iframe" loading="lazy" scrolling="auto" class="optanon-category-C0004 " data-gtm-yt-inspected-91172384_163="true" id="77006232" data-gtm-yt-inspected-91172384_165="true" data-gtm-yt-inspected-113="true"></iframe>

Artificial intelligence is heavily employed in video games for the purposes of non-player characters that can either assist or oppose the player in a number of ways. Combat-driven video games such as first or third-person shooters provide an ample backdrop for innovation in both technology and design. So what happens when you come to make a shooting game aiming at defying modern conventions? Not just deviating from expectation, but making us question the very games we play and the choices we make as players. In this instance I'm going to look at a game that did just that, Yager Development's critically acclaimed 2012 third-person shooter: Spec Ops: The Line.

On the surface, Spec Ops is but another cover shooter in the mould of Microsoft's Gears of War or the Ghost Recon series by Ubisoft, but this presentation hides a much darker tale told against the backdrop of war-torn Dubai. The AI non-player characters are instrumental in telling that tale and I'll be taking a look at the design of the AI systems, the significant changes made during Spec Ops long and troubled development cycle and how both ally and enemy alike are designed to support the narrative.


EXPECT SPOILERS FOR 'SPEC OPS: THE LINE' THROUGHOUT THIS PIECE

About Spec Ops: The Line

In the wake of the worst sandstorm in recorded history, the city of Dubai is cut off from the rest of the world. Players assume the role of Martin Walker, a delta force operative who alongside his squad mates Adams and Lugo, are responding to a SOS signal sent by Colonel John Conrad: leader of the 33rd infantry battalion of the United States army who had entered the city against orders in a failed attempt to evacuate civilians. It's been six months since the storms hit and Dubai has officially been declared a No Man's Land. The world knows nothing of the fate of the 33rd - now publicly disavowed by the American government for treason - or the local population who were trapped in the city.

Spec Ops is highly story driven; establishing a rhythm whereby Walker and his squad explore the atrocities taking place within Dubai in between major combat set pieces. The tragedy that befell the city is everywhere to be seen and as players explore it further, you learn more about not just what has transpired but the damage your presence is having upon the remaining survivors.

In time as players persevere in combat and adapt to this harsh and unwieldy environment, we come to learn of the consequences of our actions. As a result, the protagonist Walker becomes increasingly mentally unstable; unravelling as he is unwilling to come to terms with what he - and by extension you - has done in an effort to bring peace to Dubai. This core conceit of the game is for players to not only question what's happening in front of them, but ultimately whether they're doing the right thing in a game that provides no other recourse but to gun down those that oppose you.

As detailed in his book 'Significant Zero', Walt Williams worked as narrative designer, lead writer and publisher liaison for 2K games during the project and realised it would require a difficult balancing act of player agency and the clever execution of the game's intended design in order to reinforce that narrative:

"If this was going to work, Walker couldn't start off unstable. That would be cheating. When a player starts a game, they become their character. At that moment, they need to understand the character's state of mind...

...To earn Walker's insanity, we needed to break him emotionally and psychologically. There had to be a moment when Walker, under the player's control, committed an act so terrible it could conceivably shatter his mind...

If Walker's mental breakdown was caused by a moment outside of the player's control, then they would no longer be in sync and the twist would not work."

(Significant Zero, pages 241 & 242)

This required the game to be able to communicate and maintain the constraints of the story during play. As such, the AI behind both the enemy NPCs as well as the supporting characters had to be given not just theatrical direction, but allow for improvisation as each players own unique telling of the story takes place. Through a clever usage of AI tools and design integration, Spec Ops successfully delivers on this experience. But in truth, the AI systems built and how they were adopted went through significant changes during the games development.

The AI Architecture

As mentioned earlier, the project went through numerous iterations before maturing into what we now consider to be Spec Ops: The Line. During this time the AI systems went through several iterations, completely rewriting many of the core systems in a period of 3 years. The project began development in 2007 under the title of 'Stealth Ranger', during which the AI used a STRIPS-style planning system - much like that seen in First Encounter Assault Recon the subject of my first ever AI and Games video. Players could use this to give explicit commands to AI buddies in a manner akin to classic Rainbow Six games: players could assign locations for characters to take cover, to commit specific tactics, flank enemy opponents and more.

But this approach didn't sit well with the level designers: not because of the flexibility afforded to players, but rather that the AI was difficult to work with. The problem with the STRIPS-style non-player characters was that they were great at coming up with immediate and interesting strategies, but in the context of a cover shooter, it meant that the enemies frequently realised the best choice of action was to stay in cover. At this point a smart AI, did not make for a fun AI and as such a change was needed.

In 2008 the game migrated from 'Stealth Ranger' to 'Spec Ops' and again into 'Spec Ops: The Line' in 2010, with the overall design and the story of the game beginning to shift away from what these AI systems could provide. As such, the AI team rebuilt the entire system to use behaviour trees. Behaviour trees are a popular methodology in modern AAA games that I covered back in my pieces on Halo 2 and Alien Isolation. Behaviour Trees gave designers the opportunity to craft sequences of behaviours together that suited a specific purpose. However, as noted in a minute, the AI team made some small yet significant changes to the Behaviour Tree approach in order to make them more pragmatic for designers as well as maintain performance.

During this time all of the original behaviours built in STRIPS were translated over to the new system to be used. But as the game's design moved away from giving the player complete control of AI characters, these behaviours still found use in the hands of designers. In the final game players can only instruct allies to attack specific targets, heal each other when downed or commit a flash grenade when under heavy fire. However, most of the AI behaviours originally intended for the player's squad commands were retained in the final game, as designers reworked them in a number of ways throughout the campaign. This includes the likes of pushing up to cover, shooting from behind cover and blind firing. Interestingly, one squad behaviour originally intended for Adam's was the ability to deploy a portable mortar during the campaign. While this was ultimately scrapped, it is still used in the horrifying white phosphorous attack in order to achieve that desired sequence.

As mentioned earlier, Yager made one small change to the typical behaviour tree design that has a big effect on subsequent execution. Typically, behaviour trees on every frame or every couple of frames of execution will re-evaluate where within the tree it should be executing from; providing a more reactive behaviour based on what's transpiring in the world. However, with up to 8 active behaviour-tree-driven AI running at any point in time - two of which being Adam's and Lugo - this was becoming a big performance overhead, particularly on consoles. To address this, in Spec Ops all behaviour trees are entirely event driven - meaning AI characters will continue to execute a specific behaviour until an event occurs that causes them to shift to a different one. To achieve this, a sensory system was developed that processed everything happening in the game at a given point in time and distilled this data into useful facts that could be fed to the NPCs to react to.

With this system in place, the design and AI teams could work together to craft specific sequences and gameplay moments, but also leave some wriggle room for the NPCs to improvise during combat and provide a more cinematic experience. As such, major story moments such as the execution scene, the lynching of Lugo and Walker's subsequent hallucination of his ally after his death are all entirely scripted by designers.

Enemy AI Design

As we venture through the streets and buildings of Dubai, players come into contact with three different factions: the looters - armed civilians who are trapped in Dubai and fighting for survival, the damned 33rd itself and Zulu squad - Colonel Conrads' elite guard who are more aggressive and immoral than their compatriots. Each faction carries the same three enemy AI archetypes: close range, assault and long range, with each having their own distinct set of abilities and weapons. Outside of these are two special enemies used by the 33rd faction: the Commando and the Heavy Trooper. Both of which are designed to force the player out of cover, with the Commando charging the player while the Heavy is armoured, carries a big gun and proves to be a real challenge. Each archetype is designed to react differently if at all to a variety of events, such as the player pushing forward, grenades being thrown, the player reloading and many others. However, there are also a variety of dumb AI available known as 'cheapshooters' that are often used in the background to simply shoot guns and have basic reactions in larger sequences. A major design concern throughout development was to avoid dehumanising the enemies as much as possible, given they are in fact survivors of the disaster, but also feel a sense of familiarity when faced off against the likes of the 33rd, with a battle chatter system akin to Call of Duty where enemies frequently yell commands and express themselves - a point that will prove useful interesting later in this video.

Many of these archetypes have specific tweaks at design level that are aimed at building the overall experience as well as minimising performance overheads. So instead of working harder to simulate their intelligence they just outright fake it. For example, all AI characters know the location of every other AI in the game. This is largely to prevent them attempting to take cover, failing as someone else gets to it before them and then running back or to another location, which would look rather stupid. While the standard AI archetypes have to find you in the level before they can start attacking, specalists such as the Commando and Heavy always know your location: a deliberate choice to force players out of cover. In addition, not only do AI have unlimited ammo, but all their grenade throws are faked. Each of these is done for dramatic effect and to minimise issues that will occur in game. Enemies are forced to reload periodically to provide a break in the onslaught, but they also are not allowed to reload if it will break from the experience at a given point in time, such as flanking the player. Meanwhile, grenades are handled by a separate system that simply drops them somewhere near the players feet. The system assesses how long the player has been in cover, then selects a NPC within the players line of sight to throw the grenade: it will commit the animation and then whoops, a grenade lands a few feet away.

But don't worry, the systems at play also support players too! First up, NPCs will deliberately stand up when players attempt to mount cover they're hiding behind to allow you to kick them. In addition, NPCs will only target the player with grenades or flanking manoeuvres so as not to down ally NPCs too frequently and force you to go back and heal them - which is just so generous of them. Conversely, enemies will react to you throwing a grenade, but often slow enough that some of them will still be caught in the blast radius. In fact, throwing a sticky grenade at a regular enemy will force a behaviour where they run towards allies if they are in proximity.

Friendly AI Design

But while getting the enemy AI to work, your allies were a lot more taxing. Lugo and Adam's went through a lot of work to be tweaked and balanced in such a way that they are useful to player in combat and don't steal your thunder, but also behave as expected during more story driven sequences as well as at critical moments of the game.

First up, is how do the designers ensure that your allies continue to move around the world with you as expected? This is achieved through what Yager refer to as Squad Triggers: invisible volumes in the world that are placed by designers that when either the player or an ally walk into them, it tells them exactly what behaviours to start executing and often where in the world they need to go. Hence they can follow you through buildings, move across zip lines and the like with zero hassle. In addition, these triggers often influence movement delays - such that they typically don't overtake you lest you permit them, but also triggers specific voice lines to occur that allow for the story to play out.

JikGuard.com, a high-tech security service provider focusing on game protection and anti-cheat, is committed to helping game companies solve the problem of cheats and hacks, and providing deeply integrated encryption protection solutions for games.

Read More>>