Featured Blog

How Spreadsheets Power Civilian AI in Watch Dogs 2

How a fuzzy logic system combined with thousands of rules powers the civilian NPCs in Watch Dogs.

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

The Watch Dogs franchise is one that is focussed on the increasingly blurred lines between personal security and the compromises made that further enable corporate and state-powered surveillance. But in order for this work, it’s reliant on people. As players take control of gruff anti-hero Aiden Pearce, hacktivist Marcus Holloway and whoever you want in Watch Dogs: Legion, players aren’t just hacking into computer systems, they’re spying and invading on other peoples lives, hence the series needs to have lively and interesting non-player characters in the world that make the hacking process relevant but also interesting as a game mechanic.

So let’s take a look at the civilians in Ubisoft Montreal’s 2016 release Watch Dogs 2, in which Dedsec hacker Marcus is intent on bringing down CtOS 2.0 in a scaled reproduction of the San Francisco Bay Area. We’re going to take a look at how civilians are designed to reflect the different areas of the game map, what AI systems are used to ensure characters create interesting behaviours and respond to what’s happening around them and how the real secret to making it all happen in the game, is a giant spreadsheet.

Spreadsheets in Game Design

On one hand, you might be confused why a spreadsheet would be used in the making of a AAA game such as Watch Dogs, you may have dismissed it as a stupid idea and laughing at how ridiculous it might sound, but it’s a lot more commonplace than you might think. Having a working understanding of spreadsheet software is a valuable tool in game development. Designers can sit down and build progression and XP levels, balance in-game economies, or provide rulesets that influence entire gameplay structures all from the comfort of a normal spreadsheet application such as Excel and later have that injected into the game. This can be quite pervasive, to a point that some designers will spend more time on a project working in the spreadsheet than they will in the actual game engine.

In the case of Watch Dogs 2, for all of these characters to work, to have such a diverse range of unique behaviours, of combinations of character traits and all the weird and quirky bits of information that appears when you hack into their phones, designers have to spend weeks if not months of their time populating all of that information. And it’s much more amenable for a designer, and the development team as a whole for this dataset to be populated outside of the project and edited when changes need to be made. And then it gets injected into the game when it’s ready. And that’s really why I wanted to present this work, given it’s a nice example of a simple albeit effective AI system working in conjunction with a massive spreadsheet full of data that the game then exploits. It’s through this approach that Watch Dogs 2 populates the Bay Area with diverse and reactive non-player characters that generate systemic gameplay moments. So let’s get into how it all works.

Watch Dogs 2 Civilians

The goal of Watch Dogs 2‘s civilian AI was to create what is known within the development team as the ‘anecdote factory’. A system that could create small narrative moments throughout a players time in San Francisco. A big part of this was to ensure it was not scripted, but instead provide opportunities for simple albeit expressive AI characters that react to events around them, as well as one another. All designed in a way that feels emergent and interesting, to a point that it becomes part of the player’s experience and a story that you will then share with other players.

This is a critical element to introduce in Watch Dogs, given so much of the game is about hacking into other peoples lives, either to help you further your own agendas or to make their lives better or worse. So these characters need to appear like they’re real people, or as close as possible to it without it being a massive computational burden. And a key part of bringing these characters to life is not just that they’re responsive to the world around them, but by introducing diversity such that it helps create a broader range of gameplay situations. This isn’t just in the character models, but also their personalities and behaviours. The bay area is a great space within which to enable this kind of diversity, given you have Silicon Valley programmers up the road from Stanford University students, the suburban regions and docklands in Oakland, plus all the hustle and bustle you come to expect from downtown San Francisco.

Plus there is the issue of coherence, can the player read from the animations and behaviours what the context is of their interaction? This is difficult as it is, but becomes even more challenging when you want each interaction to emergent, given the situations that arise should be unpredictable. But the resulting chain of events should make sense. Making it purely random will strip it of any intentionality, but enforcing strict rules of how characters will respond will result in it feeling static and formulaic. This was actually a problem that the team role played in the Ubisoft offices, running what were known as ‘iPad sessions’, where they would improvise scenarios to try and understand the requirements of the system they were going to make. And once they got the system running, they used an in-engine recording tool to allow them to rewind and observe reactions as they happened, so they could debug them for errors but also share them around the developer team using an internal video site called Flare.

The resulting system – detailed in a 2017 GDC talk by Roxanne Blouin-Payer – is broken down into two main systems and we’ll talk our way through each of them in this video.

  • A reaction system that uses hundreds of unique rules and combinations to dictate how a character will respond to an event in the world.
  • An attractor system designed to create events for the NPCs in the world to react to. This also includes the dynamic attractor system, that is used in a manner akin to an AI director to generate attractor events in line with game world events such that it keeps the game world interesting as you go about your business.

So let’s walk through each of these in-turn, look at how it manifests in Watch Dogs 2 and where that all-important spreadsheet was actually adopted.

Reaction Systems

Building a reaction system for NPCs actually requires a lot of complexity, given they need to be able to decide how to respond to given stimuli, but also make responses that seem plausible. Hence you might trigger a specific event in the world that surprises or shocks them but it has the knock-on effect of pissing them off and this influences what actions or behaviours they execute next. Afterwards – provided you haven’t made any more disturbances – ideally that character will have calmed down and return to a more chill state and continue on in their day. But on top of this, those emotions need to have a sense of continuity, given it would otherwise mean that characters reactions are bipolar in nature if they oscillate from happy to angry and back to angry again.

To address this, there is an emotional mood system in Watch Dogs 2, where a character can be relaxed, happy, anxious or angry at the current situation. As you can see in the diagram, this system is very much a finite state machine, where a character can transition out of the relaxed state into any other and there are specific rules on which emotions can be switched between. Hence they can transition from happy to angry, but not the other way around. But also, there are cooldowns, which the character will revert back from any emotional state back to relaxed over time.

When an event occurs that triggers a response, they might change their emotional state, or stay in the one they’re in. They then decide what reaction they make to a given event and execute it, ensuring they’re looking at or facing the event that triggered it – with rules for each behaviour having a comfort zone that dictates how far away at minimum they need to be to execute that reaction. This actually makes a lot of sense as you don’t want to react to someone being beat up in the street by standing right next to the them. After the reaction is complete, they may return to their default behaviour, but their emotional state is detached from the action. Hence they might get angry at you, turn and yell in your face and then continue about their business. But they’re still annoyed for a period of time until the anger emotion wears off.

As you can imagine, this relatively simple system can enable a lot of functionality. Given you could customise the cooldown rates for emotions, or what events in the world that will trigger an emotional transition – or even state that the character simply ignores the stimuli when presented to them. Hence it’s from this system that Watch Dogs 2‘s characters get much more interesting.

The secret ingredient is giving each character a personality, meaning that when they spawn into the world, they not only start in a given emotional state but the makeup of their personality traits influences how they react to a given circumstance. Hence each character is broken down into five traits: violent, pessimistic, optimistic, neutral and heroic. This means you can have two people right next to one another, where one is much pessimistic and violent while the other is much more optimistic and neutral. Meaning that if they’re both in a relaxed emotional state, and the player emotes or does something nearby they’ll react to it in a completely different way.

And this is where the spreadsheet comes in, the spreadsheet contained the data for what is known as the reaction matrix. This contained all of the rules that dictated how characters respond to specific events including…

  • What the character was doing at the time the event happens
  • What their emotional state was
  • What type of non-player character they were
  • What type of incident occurred and how intense it was
  • Whether they’re sitting around, standing, walking or driving a vehicle.
  • If they’re driving a vehicle, what type of vehicle was it?
  • And many many more.

All of these rules help catch edge conditions where you don’t want characters responding, but also helps give nuance by having characters react much more aggressively to being caught in a pile-up at an intersection versus the player accidentally bumping them with their motorcycle. These are all written by hand by designers and there are over 700 different rules for an NPC to react. But in addition to all of this, the reaction matrix also included over 200 rules for what audio barks are to be played based on the final reaction the NPC selects as well as another 200 animation rules to tell the NPC what animation they should play alongside it.

In the final game, this spreadsheet containing thousands of rules was imported into the games data files and parsed into XML. Naturally writing code that does this is relatively straight forward, hence the designers could make changes in the spreadsheet and re-import the reaction rules while the game was running, making it much easier to test and debug. In addition, the team found it was easier to write macros in Visual Basic to help speed up the rule creation process in excel rather than writing tools within the game engine itself.

But we actually missed something here. All of these rules are for specific personality traits and emotional states. But as mentioned earlier, each character is comprised of multiple personality traits. So how does the system know which one to select at runtime if each part of their personality responds to the same event in different ways? The game uses a technique known as fuzzy logic – which is derived from fuzzy mathematics and was very popular in expert AI systems back in the 1980s. With fuzzy logic, the system reads all of these different inputs based on the reaction matrix rules and weights them against the strength of those personality traits. These fuzzy inputs are passed into an inferencing system and from that, it decides how best to respond. Meaning that it will figure out the best response for the character to make based on all the different reaction rules its personality triggered.

Given the large number of possible reactions that a character can have, combined with how many different ways they can be combined in the fuzzy logic, there are quite literally millions of possible results that can emerge from the NPC reaction system.

Attractor Systems

Now that these simple AI characters can react to the world around them there needs to be something for them to react to. Relying solely on the player to trigger in-world events is risky, given it means that the rest of world is quite static and lifeless. As a result, there’s a need for some characters to be in the world that don’t just react to what happens, but are also the source of events for others to respond to. These are referred to by the developers as provocative agents, where their job is largely to trigger responses from others NPCs around them. This are injected into the game through use of attractors: these are special activities that are placed into the game world often associated with a specific game object, such as a geometric location, a staircase, a vehicle and much more. These attractors are designed to capture the attention of non-player characters as well as the player as they’re moving around in the world. Attractors are placed in the world by hand by designers, given it will make sense for that attractor to be there. So something like seeing people doing yoga in the park, or sitting around and playing guitar are typically designer-created attractors.

But on top of this, there are also dynamic attractors. These are the same attractor characters, but this time they’re generated at runtime and placed into the world courtesy of an event manager. This could result in a romantic rendezvous, or people casually bumping into each other and having a quick chat on the street, to something more aggressive such as an argument leading to a fistfight or someone being mugged.

Other Design Issues

So now that these NPCs worked as intended and the attractor system was helping to bring San Francisco to life, there was actually a pretty major problem they needed to overcome – the mission designers weren’t using them. Why is this? Well lest the player did something to provoke a reaction, they didn’t really care what Marcus was doing at any point in time. Whether you’re in the church of New Dawn, or the offices at Nudle, NPCs should pay attention when the player is doing something suspicious or out of the ordinary. Naturally, the guard AI already did this – given they ran on the separate AI combat systems – but the civilians should also be thinking of this too.

Hence there is a special variant of the civilian AI known as ‘affiliated civilians’. These NPCs look exactly the same as a regular citizen but can use the same observation and awareness systems as enemies. So when you go into missions in these locations, these NPCs look exactly the same as everyone else but they’re designed to recognise when Marcus goes into an area he’s not supposed to and can alert guards if they spot suspicious activity. In addition, their response to combat isn’t as strong as they would be in other locales of the game. So if they see a security guard running up to fight you, they don’t panic because it makes sense that they’re trying to bring you in. But on the other hand, if the player is then super aggressive and guns blazing, they’ll respond to that accordingly.


Watch Dogs 2 is but one of many games that try to diversify the types of characters players meet in the opening world. But unlike so many others, it relies much more on creating characters that fit their environments more accurately, as well as enabling them to respond to the world around them. Thus enabling a players behaviour in-game to have much more weight and substance.

At this time of publication, Watch Dogs Legion has just been released, vaunting it’s ambitious ‘Play as Anyone’ concept, where now not only can you manipulate and provoke these characters, you can now explore their backstories and ultimately recruit them to become a playable character. While ambitious, the seeds are sown here in Watch Dogs 2 and hopefully, we’ll be able to see how they pull it off in the future.


  • “Helping It All Emerge: Managing Crowd AI in Watch Dogs 2”, Roxanne Blouin-Payer, Game Developers Conference (GDC) 2017



Latest Jobs

Xbox Game Studios

Redmond, Washington
Technical Lighting Artist


Hamburg, Germany
Game Designer - Elvenar

Six Foot

Houston, TX
Six Foot Director, Player Relations

Hometopia Inc.

Lead Engineer
More Jobs   


Explore the
Subscribe to
Follow us

Game Developer Job Board

Game Developer Newsletter


Explore the

Game Developer Job Board

Browse open positions across the game industry or recruit new talent for your studio

Subscribe to

Game Developer Newsletter

Get daily Game Developer top stories every morning straight into your inbox

Follow us


Follow us @gamedevdotcom to stay up-to-date with the latest news & insider information about events & more