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.
In collaboration with Ubisoft and Massive Entertainment, I present three blogs exploring the AI behind Tom Clancy's The Division 2, including excerpts from my interview with the Lead AI Programmer of the franchise, Philip Dunstan.
Part 1 of this series, where we discuss enemy AI design can be found here.
Tom Clancy's The Division 2 introduces players to a war torn Washington D.C. A battleground not just in the streets, but the hearts and minds of its civilians as they fight to regain a semblance of order that is true to the values this city - and its country - are built upon.
It's been seven months since the Dollar Flu destroyed New York City and humanity is clawing back piece by piece, presenting a new game design challenge for developers Massive Entertainment: building an open world game that is dynamic, emergent and immersive. Keeping players on their toes and giving a sense of life to the world.
This leads to enemy factions wandering the open world looking for trouble, friendly survivors patrolling near their captured settlements, supply convoys that either need to be defended from enemies or raided for extra goodies, or supply caches air dropping into DC, resulting in all sorts of trouble.

Continuing my discussion with Division 2's Lead AI programmer Philip Dunstan, we discussed the process of building a system that allows for all these dynamic events to occur, the problems that arise when balancing these elements of systemic game design and the challenges faced as the established tools and systems migrated from the bitter cold of New York City, to the sunny streets of Washington DC.
Immersive Non-Player Characters
Philip Dunstan: "In New York you could stand on a street corner for a long period of time because there was very little movement through the open world. But in Washington if you stand a street corner for any length of time, you're going to be engaged in combat."
In the first Division New York City is designated a quarantine zone. It's become a tomb, a monument to the devastating chemical attack just weeks prior and hence the number of non-player characters (NPCs) is relatively minimal, with pockets of scavenging friendlies and gangs of enemies found throughout the open world. But as the franchise moves from the chilling winter winds of the Hudson to the warmer summer breeze of the Potumac, the team at Massive wanted to increase the impact and spread of both friendly and enemy non-player characters in the game map.
Philip Dunstan: "As part of the immersion we wanted to give the NPCs a lot of purpose for being in the world. And some of this came through our design, it's six or nine months after the outbreak. Washington has gone through the phase that everything is madness and chaotic and now the civilians are starting to group together into settlements and the settlements have structure and different factions all their own strongholds. We wanted to make that apparent not just through the story but through the players experience of seeing the NPCs interact and move through the open world."
To achieve this, the development team put together a Living World Activity system into the Division 2, giving specific roles to NPCs as they enter the world and ensuring that they perform a given task or duty. So let's walk through how it all works and then some of the weird and interesting problems that emerged as the existing AI systems were being adapted to work within the Washington DC map.

The Living World Activity System
Philip Dunstan: "We wanted Washington to feel much more alive, we wanted it to feel like there was always something happening that you could easily find a group of civilians or a group of Hyenas and so it meant having a system that let NPCs move through the world."
The Activity system within the division two allows for a variety of different sequences to be executed each with their own objective. Throughout the execution of the sequence a NPC will assumes a role or duty within the world and as assigned to a post within a set space or space to operate within. What that means when you see a groups of NPCs travelling through the open, be it as a patrol team near a stronghold, a convoy moving between outposts or as a unit gathering resrources from an area with food or water, each NPC has a defined purpose within the activity to complete.
As mentioned each NPC has a given role or duty to complete for their assigned objective. These are split into two types: the special role which is given to one or more NPCs at the beginning of the action being executed, or the unscripted role which is assigned in an adhoc fashion depending on what's happening in the world at that time. A special role may be the NPCs that are gathering the resources, or carrying the boxes of supplies in a convoy. While the unscripted roles are the guards providing overwatch, either standing in a fixed position, wandering a patrol path or taking control of a mounted weapon.
But in order for NPCs to have a role, they need to know not just what roles are available in a particular activity, but where they should be doing it. Hence every activity has a set of posts attached to it. Each post is set by designers to identify what duties can be executed at that post, the locations they should execute the duty from and the minimum number of NPCs that are required to satisfy it, given you might need two or three NPCs to maintain overwatch or patrol a region. These are different types of locations that can be attached to a post: volumes for when they're gathering resources or guarding a region of the map, waypoint paths that are for patrol duties and fixed points such as a mounted weapon.

Whenever the active objective changes, the server attempts to assign NPCs that already have an active duty to a new one in context of the current task. But also priotises what posts should be assigned, so mandatory posts that really help sell what these characters are doing are filled first, with other unfulfilled posts being populated depending on the makeup of the remaining NPCs.
This all does a great job of reinforcing the performance theatre of the game: characters know where in the world they should be standing and what their job is at that point in time. But what happens when an opposing factions appear - or the player in fact - and things start to kick off? Well each NPC post does actually dictate whether or not it should be maintained in combat and if so they'll continue to operate the behaviour once the fighting starts. After all, there's no point standing around on that mounted machine gun if you're not going to use it. Plus in the event an AI decides to execute a specific behaviour, the behaviour can dictate whether or not to release itself from a given post and get into the fight and provides a nice continuity between passive and active activity.

Unexpected Challenges
So with this fairly extensive overhaul of the systems to facilitate the introduction of more dynamic and systemic AI throughout the open world. There were still issues the team had to address, and much of that comes largely from the change of scenery:
Philip Dunstan: "The openness of Washington was one of the biggest challenges coming from New York. It's not just the fact that the streets in New York are so narrow and also high skyscrapers on either sides of the street, hyper tall buildings, it's also the amount of traffic you expect to see with broken-down cars and buses in New York meant that we had a lot of control over very long sight lines. So the combat tended to be you know quite short range or mid range combat even in the open world.
And you get to Washington and one of the things we wanted to show was a diversity of environment that wasn't necessarily there in New York. We wanted wide boulevards, tree-lined boulevards, we wanted big grassy open spaces, we wanted sort of you know more sort of university-type, queenstown-type locations and that put a pressure not just on the performance as you mentioned but it actually put quite a bit of pressure on our NPC behaviours and our NPC systems. We hadn't really you know, when we'd created the NPCs for the Division we had designed them around a short-to-medium distance combat and now something we had to deal with you know a lot longer sight range. And what happens if you engage with a Rusher at 60 metres are they just going to run towards you for 15 seconds.