'AI and Games' is a crowdfunded YouTube series that explores research and applications of artificial intelligence in video games. You can support this work by visiting my Patreon page.
One of the most challenging and unforgiving genres for artificial intelligence in video games is stealth. Players are tasked with sneaking into locations and conducting their business, be it to steal items of interest or eliminate targets all the while adapting to new threats and exploiting opportunities as they arise. There is an expectation that stealth games provide a real challenge - especially on the highest of difficulty levels - but all the while providing small areas of opportunity for players to exploit. This presents a lot of challenges for developers when creating enemy opponents. They need to be smart and react to the world, communicate their thought processes such that player can compensate but ultimately provide a fair and balanced experience as best as possible. In this blog let's look at how to build balance in stealth games by exploring the inner workings of Splinter Cell: Blacklist.
The Challenge of Stealth AI
Blacklist, developed by Ubisoft Toronto and released in 2013 is the seventh entry in the long running Tom Clancy's Splinter Cell franchise. The game is a marriage of previous entries in the series in that it allows for players to take different approaches towards completing each level. Balancing the stealth puzzles of the series roots alongside the more action focussed gameplay exhibited by 2010's Splinter Cell Conviction. As you take charge of Sam Fisher in Blacklist, you can decided how bombastic or otherwise you want to tackle each new locale.
This presents a massive challenge for level design, game pacing and the design and development of AI characters, since this effectively creates two games in one and the games systems need to effectively manage the transition from the stealth into the combat game if the player makes a mess but also switch back when things die down. Stealth AI is already a challenging problem to solve. Given enemy non-player characters must satisfy several criteria.
First of all the AI characters need to be consistent in their response: NPCs should recognise the world is changing around them and go into a heightened state of alertness. These responses need to be consistent across the gameplay experience such that you can rely on specific tactics to lure enemies into positions that either compromise the security of the patrol routes established or their personal safety.
Secondly there is the issue of communication and feedback: if a character notes something is not right, or spots the player from far away, not only must they act in response, but they must effectively communicate what their intentions are. This includes their animations, talking aloud to themselves or communicating with other NPCs in proximity. Given the player needs to know what they're thinking and doing in order to get themselves out of the current situation.
Lastly, there is the issue of predictability vs novelty. Ultimately you want the responses and feedback to be consistent to a point of predictable. That said, predictability means the game can become repetitive and in-turn stale after several hours of play, largely because players are unpredictable and difficult to account for. Hence there is a need to maintain novelty where NPCs might do something a little different the next time around, or new enemy archetypes are introduced that force players to approach problems differently.
All of this comes under the umbrella term of 'fairness': you want players to develop their own idea of how the games systems will operate such that they can exploit it to their advantage. The more you play the game, the stronger your understanding becomes as new concepts are introduced and prior knowledge is reinforced. Hence playing through the game on that first playthrough versus the second or even the tenth is a different experience and higher difficulties put that knowledge to the test. That said, this isn't something that will work for everyone, as fairness is entirely subjective and may differ from player to player.

The Four Pillars of Stealth AI
When discussing how AI systems need to support fairness Martin Walsh - Blacklist's lead AI developer - had this to say at the 2014 Game Developers Conference:
"If your opponents feel dumb then you get no real satisfaction in beating them. But you know what's interesting is not being dumb doesn't necessarily mean being smart. And what it actually means is always being plausible."
"It's interesting to note that there's often a conflict that exists between fairness, consistency and intelligence and that's something that's important to be aware of."
Martin Walsh, "Modeling Perception and Awareness in Splinter Cell: Blacklist", Game Developers Conference (GDC) 2014.
These ideas are core to the design of the Splinter Cell franchise, not just Blacklist specifically and as Walsh explained in his GDC talk, there are four key pillars of enemy AI design that need to be balanced in order Splinter Cell - or any stealth game for that matter to work effectively.
The Visual Perception of the Non-Player Characters: How do friendly and enemy AI see the world around them and spot the player if they're exposed.
Environmental Awarness: Meaning does the character have some understanding of the local geometry. Do they notice when doors or windows have been opened or closed. Or when things go loud do they know good cover or chokepoints to establish.
Auditory Perception: Meaning how do we model the NPCs ability to hear noises or more critically, what the player thinks NPC should hear.
Social and Contextual Awareness: Recognising what's happening in the world around them as the player eliminates their comrades, and even just having realistic conversation between guards as they're waiting for the player to come in ando their business.
These principles hold not just across Splinter Cell and stealth games, but a variety of genres. In fact we recently explored the sensory systems of the xenomorph as we revisited the AI of Alien: Isolation and as you'll see there is a lot of overlap between the systems in Creative Assembly's horror game and what I am about to cover. And this makes sense, given a lot of what I'm exploring in this episode isn't new, but has went through years of iteration and refinement within game development. So let's take a look at how the four pillars are managed in Splinter Cell: Blacklist.
Vision
First up let's look at the Visual Perception of AI characters and how to balance this for stealth games. Vision systems are built to allow for AI characters to recognise objects within defined fields of view, typically through use of view cones: where a cone (or a triangle if it's a 2D environment) of a fixed radius and height is projected from the front of the non-player character. If an object intersects with the shape, it registers a signal that says that object is 'seen' by the AI. Typically the longer an object stays within the cone the signal becomes stronger over time. Hence this is used to ensure that you're not spotted immediately upon intersecting the view cone, as an AI will typically wait until the signal is strong enough to recognise you.

Image Credit: Walsh (2014)
Image Credit: Walsh (2014)
Now view cones are a well-known and commonly used technique, but they're fundamentally flawed, because that's not how human eyesight works. A view cone is often a fixed angle and distance ahead of the character, whereas humans have close to 180 degrees of vision. So one solution is to make the view cone wider, but this presents another inconsistency, given our eyes are built to allow us to focus on specific areas, making what we see sharper and more clear. But in the process of doing so makes everything else in our peripheral vision blur.

Image Credit: Walsh (2015)
Image Credit: Walsh (2015)
Hence Blacklist, like many other games, adopts multiple view cones to represent different types of vision and the detection thresholds and rates of signal increase vary depending on whether they're designed to model close or distant vision. But the thing that Splinter Cell does to stand out is that view cone isn't a cone-shaped, it actually looks a lot more like a coffin. This ensures the NPC maintains clarity of vision in front but also prevents them from having strong peripheral vision at longer distances, making it more realistic. In addition, the size and shape of each cone is tweaked for each difficulty setting, allowing for more blind spots on lower difficulties, but giving expert player a run for their money.
Plus for spotting the player, there is an additional suite of sight checks that are made given the player is more or less exposed depending on the stance they are currently in. Sam Fisher can be in a variety of different poses, with some - like being in cover - designed to conceal your position. Hence in order for a the vision code to detect the player as seen, they not only have to be within the cone itself, but also the character has to successfully run multiple sight tests on the player to see how much of their body is exposed. The NPC runs a raycast from its eyes to eight of the bones in Fisher's skeleton. The more of these bones that are visible without anything in the way means the character is more exposed. Depending on the stance the player is in, the enemy NPC needs to succesfully see a minimum number of these bones before it will recognise your presence. Hence standing in the open versus crouched behind cover have different rates of detection.

Image Credt: Walsh (2015)
Image Credt: Walsh (2015)
But despite this more nuanced system, there are still special cases where, irrespective of an AI characters vision, designers wanted more control over how exposed a player is in certain locations. Hence there is a special custom cover point system that allows for designers to tweak the players visibility at specific cover points, allowing for more control over gameplay in each mission.
Environmental Awareness
Next up, let's look at environmental awareness, which encompasses all of the knowledge that a given AI character can have about the world and the ways in which it can reason about that information once it has been gathered.
This is driven by what is known as TEAS: the tactical environment awareness system that - like many of the AI tools in Blacklist - was originally built for Splinter Cell: Conviction. It contains a variety of information about the topoggraphy of the local environment as well as what objects are in the local area that the NPC should be aware. TEAS was expanded upon in