The AI of Hitman (2016)

Aug. 7, 2019
protect

 

 

<iframe title="Sandbox Assassin: The AI of Hitman (2016) | AI and Games #45" src="//www.youtube.com/embed/km_DYozYh54?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 ot-vscat-C0004 " data-gtm-yt-inspected-91172384_163="true" id="738547004" data-gtm-yt-inspected-91172384_165="true" data-gtm-yt-inspected-113="true"></iframe>

AI and Games is a crowdfunded video series about research and applications of artificial intelligence in video games.  If you like my these write-ups, please consider supporting the show over on Patreon for early-access and behind-the-scenes updates.  If you'd like to work with us on your own games projects, please check out our consulting services provided at AI and Games.

The 2016 release of IO Interactive's Hitman brought the franchise back to its roots, of creating rich and interesting scenarios in which Agent 47 needs to eliminate his targets, often in improvised and impractical ways. To achieve this, the game has a myriad of AI systems under the hood, and this is what we're here to explore. We're going to dive deep into the suite of AI systems built to support the current generation of Hitman: creating responsive NPCs, bodyguards, crowd systems, AI-driven animation and more as players once again become the sandbox assassin.

About Hitman

Players in Hitman are tasked with killing horrible and unscrupulous individuals that the world won't really miss. But in each instance it's more about the unique stories that players can craft for themselves as you eliminate targets in nail biting or simply hilarious ways. Hitman is laced with systems that enable you to experiment, improvise and react to changes in the larger story that's playing out and the progression being made towards eliminating your target. Poison drinks as a barman, snap necks as a masseur, scare someone as a plague doctor, even gain the trust of a recording team by playing the drums. The game provides a range of fun and often bespoke methods to zone in and remove your quarry in increasingly more complicated and expansive scenarios. Whether you're walking the catwalk of Paris fashion week, to sneaking through political upheaval in Marrakesh, your targets are found in dense, lively and complicated environments, with personal security, local law enforcement not to mention the general public proving to be an obstacle. But this is where the game becomes really interesting, as players can blend into their surroundings, assume disguises and manipulate the world around them all in an effort to get one stop closer to the target, deliver some karmic retribution and subsequently escape as the world around them is unaware of their presence.

Hitman is at it's most satisfying when your preparation and planning come to a head and are executed perfectly and it requires numerous AI systems to pull it off. In this video we're going to focus on four key systems, how they work and what they do to help build the Hitman experience:

  • A situation-driven behaviour tree system, where over 300 characters in a given level can make decisions about what to do based on what they know is happening around them and react to circumstances around them and often play directly into the players hands.

  • A responsive and pragmatic bodyguard and security system for ensuring targets become all that more difficult to reach and will be rushed to secure defensive locations in the event they become compromised.

  • A powerful crowd behaviour management and simulation system that enables for over 1000 crowd NPCs to be active in a given level but can still react to actions the player executes.

  • And lastly a finely tuned animation framework that ensures all of these characters look and behave as realistic as possible.

I'm going to explain how all of this works as well as some of the finer design tweaks adopted for both the 2016 release as well as the 2018 sequel. However, before in order to talk about the AI of either game, I need to take a look at where the current AI toolchain started and the core principles of how it is designed and to do that, we're going to take a look at Hitman Absolution.

Released in 2012, Hitman Absolution was a more streamlined and linear interpretation of the franchise's formula that - while not as critically acclaimed as the more recent entries - is the basis of the core technology and tools used in both the 2016 and 2018 releases. One of the big reasons for this, is that Absolution was the first entry in the franchise since 2006's Hitman: Blood Money, given the intermittent years at IO Interactive were spent on the Kane & Lynch titles as well as Mini Ninjas. Hence Absolution was building new tools and systems that better reflected the teams ambitions for the coming years. The core architecture of Hitman's non-player characters AI, as well as the systems for crowds and animation were all built for Absolution. Then embellished upon in both the 2016 and 2018 Hitman releases.

Core AI Architecture

Hitman's AI is built to cater to the variety of playstyles that Absolution and subsequent games have afforded. This means the system supports you approaching using stealth tactics, wearing disguises and blending into your environments - referred to as 'social stealth' by the developers - or taking a more aggressive approach and going in guns blazing.

But in addition, it's built to have NPCs living their lives as expected, often with some sort of established routines of behaviours: they're serving drinks, applying makeup, guarding entryways, cooking dinner, whatever is needed to fit the fiction of the location. These routines need to be predictable and reliable - given players rely on this sort of predictability in stealth games - but can be interrupt as they investigate the many, many, many items and objects that players can manipulate in the world. Whether you're turning off a motor, causing a sink to overflow, puncturing a fuel tank or playing a video tape. Depending on the type of interaction, it will either draw characters to them with immediate effect, given they interrupt the characters activity, or will a more delay interruption to specific characters routines such that they will see what you've done sooner rather than later. This is useful for some of the more specific actions that lure targets into locations, given you don't want to have to wait 20 minutes for the payoff, but at the same time if they run over immediately after you triggering the action, it will seem stilted and forced.

Hitman's core AI is reliant on behaviour trees: arguably the most common format for modern game AI behaviour management. Behaviour trees take a top-down approach to structuring behaviour and how characters respond to specific circumstances. With behaviours selected often due to specific conditions in the world and resulting in single or multi-action sequences as they respond to what the player and other game systems are doing.

But before the behav iour tree can make a decision, each character has to know what's happening in the world around them. To do that, each active AI character in the world has a knowledge base. A knowledge base is comprised of two sets of data: public knowledge, which is information that is made public about a given item or character as well as information that reflects its state. But also there's private knowledge that a character will maintain about last known positions of objects or characters and retains a history of knowledge about specific items. Hence a character will notice when items in proximity go missing or are tampered with and similarly won't keep trying to find or interact with characters that are either missing or dead.

The knowledge base is accumulated by taking all the information happening in the game world at a given point in time and distilling it down via both sensors and services. Sensors allow characters to update their personal data and react to changes as they see and hear things in local proximity. Meanwhile services update the shared knowledge base. Three of the most common services are the Disguise, Deadbody and Hitman services. The Disguise service is used when Agent 47 is wearing a costume and helps characters to know whether that outfit will look suspicious to them or not. Meanwhile the dead body service helps characters in local proximity understand that a dead body has been found in local proximity recently. Lastly, the Hitman service allows for common knowledge of Agent 47 to be shared, such as whether the player is compromised and where in the world the player was last spotted. What's fun about the sensors and services is that they provide a fun balance of contextual knowledge, but also leave gaps for players to exploit. The sensors provide immediate information about the world, but can be interrupted by breaking line of sight or distracting them. Meanwhile, services are not omnipotent and only update periodically. Hence a lot of information from the services can become out of date pretty quickly and that leaves scope for the player to manipulate characters to suit their needs.

But now that the AI has all of this information, it needs to make decisions about how to react. Each AI character can enable one of a set of goals that drive the decisions they're about to make. With these goals selected, it will then use the behaviour tree to make a decision about how to behave next. I still haven't explained that yet, but I'm getting to it.

To diversify the gameplay, the game breaks down AI-driven NPCs into two main types: Civilians and Guards. In each instance, it impacts the information stored in their knowledge base and the types of goals they can assign themselves.

First up there's Civilians. These characters are typically passive in nature, but will spot more extreme behaviours as suspicious or alarming. This can activate goals such as confronting the player and alerting guards but it doens't allow them to go into combat. Two great example of this can be seen in the Paris fashion show level and the Bangkok hotel in the 2016 Hitman where civilians with different knowledge base profiles result in different behaviour. The guests are a lot more passive but will react to your behaviour if it proves too excessive, while staff and the entourage surrounding your targets are much more likely to react to your shenangans and confront you.

Secondly there are guards. These are naturally the players main adversary and will engage in combat with you as well as respond to more extreme circumstances such as the discovery of dead or unconscious bodies as well as weapons and other sensitive objects being found lying out in the open world. As mentioned already, Hitman 2016 introduces bodyguard AI that actively follow and guard a VIP as they move around an environment, while still leaving them free to explore the world themselves. This requires an entire separate system to operate and I'm explore that later in this video.

Now given all this information and the goals that have been activated. The behaviour tree system is built to have characters do one of two things: they either execute behaviours on their own or they join 'situations', where behaviours are coordinated by a group. A behaviour is one or more actions, ranging from turning to the player to interact or talk with them, moving to locations in the world, entering combat or interacting with objects the player might have manipulated. You'll notice playing the game that a lot of the Targets will execute specific behaviours once the player has manipulated the world in a particular way. This is because this aligns with specific goals the Targets should complete once certain conditions are met - meaning that they deliberately put themselves in precarious positions for you to kill them.

Meanwhile situations often arise when events occur in the world that have a larger impact, such as when dead bodies are discovered, the player is compromised or the target has realised they're under attack and try to flee. In these cases, characters will recognise what's happening around them and join a situation. Meanwhile the situation dictates who does what and they all play their part in the fiction. So for example in the event you open fire on the crowd at the fashion show, the guests and staff will often flee and call for help, while the guards will hunt you down and open fire.

The behaviour tree system was first devised in Absolution and has since been heavily optimised and improved for both the 2016 and 2018 releases. It utilises a level-of-detail or LODding system. Meaning that while there can be over 300 active behaviour-tree-driven AI in a given level, the ones farthest away from the player update their behaviour less frequently as the CPU resource used for updating AI prioritises those closest to you. In addition, the animations of these distant AI are either dialled down in quality or turned off entirely. As mentioned already, the vast majority of the characters you see are controlled by the crowd AI system, but if necessary any character in a crowd can - depending on the current situation in the game - be possessed by a behaviour tree AI, effectively upgrading them a to fully responsive and coordinated character.

Crowds

Now before we get into the bespoke systems built for the 2016 release, let's tackle the second core system built in Absolution: the crowd AI framework. When first built for Absolution, it could support up to 1200 agents in a single crowd, with up to 500 of them visible at the same time. It's not something I've talked about before on the show, but crowd systems are really difficult to get right. Crowds are often comprised of lots of dummy AI, that is nowhere near as smart as your more regular contemporaries. A big reason for that there's just so many of them, but also, it makes sense given they're often just adhering to a crowd mentality, moving through a convoluted space to their ultimate destination. But in Hitman, the goal was to try and blur the line between the crowds and the behaviour-tree AI as much as possible.

Characters in crowds are placed either as individuals that are able to walk around, potentially stop and acknowledge things in the space, but there are also groups that designers have a lot more control over. A group is really useful if you have a particular activity you want a bunch of characters doing in a crowd, so as looking at a point of interest but also standing in a particular shape such as in a larger shape or configuration. Each individual character runs a system that's akin to a simple Finite State Machine, with only three main states of behaviour: standing idle, walking and what's called 'pending walk', this is useful in situations where a character wants to be moving, but the congestion of the crowd has stopped them. So while they're stuck in the crowd, they're making decisions about a better direction they can take and wa

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>>