Featured Blog

Behind The AI of Horizon Zero Dawn (Part 1)

In this first of two blogs I explore the AI decision making framework that enables the machine-animals of Horizon Zero Dawn to behave independently and as part of a herd.

AI and Games is a crowdfunded series about research and applications of artificial intelligence in video games.  If you like my work please consider supporting the show over on Patreon for early-access and behind-the-scenes updates.

Horizon Zero Dawn stands as one of the most critically acclaimed of Sony’s roster of Playstation 4 exclusives. As the hunter Aloy, players venture across the post-apocalyptic landscapes of the future to uncover the mysteries of her past and how the world fell in the years before. Humanities fall from grace has led to the rise of ‘the machines’ – robots of varying shapes and sizes that that now run free across the lands. These robotic animals are intelligent, coordinated and lethal: requiring quick thinking to survive and even greater preparation and planning to successfully destroy.

In this first of a two-part series: I’m exploring the gameplay and decision making systems that bring these creatures to life and power the core gameplay experience. I’ll be looking at not only how they make decisions to scavenge, to hunt and to survive but how they coordinate themselves in the wider world either individually or as part of a herds. Plus I explore how the game creates an ecosystem of machines that is balanced and managed across the many territories and regions of the new world.

Warning: Story spoilers for Horizon Zero Dawn.

The Ecology of Horizon Zero Dawn

The robotic wildlife of Horizon Zero Dawn dominate the landscape and hold control of territory throughout this open-world experience. Each machine carries a unique aesthetic and structure that reflects their function and purpose within the narrative of the game. As players work their way through the campaign, we come to learn of the Faro Plague – an army of rogue war-machines that rendered the world asunder – alongside the race of machines constructed by the AI known as GAIA that are designed to restore the planet to its natural glory and are largely inspired by long-extinct terran species.

As a result, the function of a given machine often holds the secrets to their weakness, players can use their Focus to scan local machines to ascertain not only their type, but vulnerabilities as well as weak points. In addition to the weak spots, a machine’s function within the narrative ultimately influences their in-game behaviour, this includes:

  • Acquisition and scavenger robots such as the Strider and Grazer. These worker class machines are typically found in open grass lands working the lands and while they are relatively docile and often flee confrontation they are nonetheless deadly when provoked.
  • Recon machines such as Watchers and Longlegs that scout the region for threats and alert nearby machines such that they can fight or flee.
  • Transport machines such as the Behemoth and Shell-Walker that gather up resources from the acquisition robots making them valuable targets. They are slower, more cumbersome and typically defended by more nimble units.
  • And lastly combat machines such as Sawtooths and Stalkers that are primarily there to attack the player and other nearby threats.

There are 28 unique machines that can be found roaming the wild lands, each with their own distinct passive and aggressive behaviours and players need to learn how best to approach them. While the greatest threats on the path to Meridian – such as the Stormbird and Thunderjaw – roam the wilds on their own, players can still run afoul of less lethal machines that operate in herds. It’s common to see the smaller robots such as Watchers, Striders, Scrappers and Lancehorns co-existing: supporting one another as they achieve their base functions. Over time these herds increase in size and diversity as players continue to explore the world with the likes of Shell-Walker convoys, packs of Tramplers and Sawtooths protecting nearby Grazers and Lancehorns.

In order to pull this off, the game requires numerous AI systems that dictate the behaviour of each robot, how they behave within a herd, the collective intelligence of the herds themselves but also balance the herds across the open world for a more varied experience.  The developers behind Horizon Zero Dawn, Guerilla Games, came to this project lacking many of the AI tools required in order to bring this experience to life.

Having previously worked on their Killzone franchise, their toolchain was largely focussed to accommodate first person shooter and none of the design challenges that faced them for a large open-world experience. As such, during the course of development they built newAI and gameplay systems and expanded existing ones within the studio to bring this experience to life and over the next two blog posts I’m going to explore the following:

  • An agent hierarchy system that dictates how each machine behaves both individually, but also as part of a pack or herd (Beij 2017).
  • The expansion of the existing planning and execution system originally built for Killzone that allows each machine to make decisions (Berteling 2018).
  • A set of sensor systems that enables the machines to quickly and effectively detect threats and investigate when necessary (Beij 2017)
  • A dynamic and intelligent navigation system that provides interesting movement patterns for both ground robots that respects the world geometry and varying machine size (Beij 2017, Berteling 2018)
  • A completely separate navigation system that catered for air-based machines such as Glinthawks and Stormbirds (Josemans, 2017).
  • An animation system that respects each machines composition and ensures they move and attack in an intelligent way (Berteling 2018).
  • Last but not least, a system known as The Collective that manages every single machine that is active in the game world and how they are distributed across herds (Beij 2017)

So let’s begin by exploring how each AI character is built to make decisions and how the game manages herd behaviour.

Agent Hierarchy

Each machine is represented in the world as a separate non-player-character AI called an ‘agent’, but perhaps more interestingly, so is each herd. Horizon Zero Dawn adopts a hierarchy whereby a machine can exist entirely on its own as an agent or as a child of a group agent – which is used to store information about herds.

An example group hierarchy [from (Beij, 2017)]

A group agent doesn’t physically exist in the game world, but it’s responsible for coordinating all agents within it. Each individual agent has its own set of sensors that enables it to hear noises closeby or spot threats in proximity. But in addition, a group agent has a blackboard system that stores in-game information a machine might want to use. This not only allows the game to keep performance costs down by storing information each individual might try to calculate on its own – like safe areas to stand in or active patrol routes – but more importantly, agents in a group can share information between each other. Hence when a recon machine spots the player, each machine can make a decision on how to respond to that information. Hence you might see acquisition robots in the herd such as grazers opt to run away while nearby combat machines move in for the kill.

Now the actual AI system used in Horizon Zero Dawn is called a hierarchical task network planner. Unlike the planning systems used in games such as F.E.A.R. that planned one action after the other, HTN planning generates plans comprised of action macros. Each macro contains multiple actions in a set sequence. This is ideal for game development given designers can put together macros of good behaviour they expect to see in-game. I’ve previously explored how HTN planning was used in Transformers: Fall of Cybertron, but it’s worth noting that Guerilla have been used HTN planning since Killzone 2 and as such this wasn’t built overnight, but has gradually matured over years of projects within the studio.

An overview of HTN planning [from (Beij, 2017)]

The HTN planner is used in two capacities by machines: individual agents can ask for a plan of action to resolve a specific task, such as finding new areas to visit, attacking a human, or fleeing to safety. Meanwhile group agents can run plans that dictate what goals individuals agents should be assigned, allows groups to actively pass information between one another within a hierarchy and potentially form new subgroups or destroy existing ones. In short, each individual machine is still largely responsible for their own behaviour and addressing the goals assigned to them and uses the planner to make decisions. Meanwhile, the groups keep individuals coordinated, re-group them based upon what’s happening in the world and – perhaps critically – assign roles to each machine such that they know what their job is to support the herd.

The Collective

Now with all of these machines being spawned into the world either individually or in groups, how does the game know what machines to spawn in the open world and where? There are designated sites across the game map where we can expect specific machines to appear either individually for machines like Thunderjaws and Stormbirds or in flocks for the likes of Striders, Grazers and Glinthawks. However, the rest of the game-world is full of herds comprised of different machines. So how does the game know when spawning in a specific machine where to place it in the world and what groups to assign it to based on the needs of the worlds design?

This is achieved courtesy of a system known as ‘The Collective’. The collective is the supergroup: all machine groups and individual machines exist in the collective. It manages the spawning of all machines into the world, keeps track of whether they’re in a group and handles their movement between groups and manages the machine ecosystem, such that performance isn’t impacted overall.

Individual machines in the world can request to join an existing open-world group if they’re on their own. This is useful feature given many machines are left isolated after the rest of the previous group either fled or have been destroyed. So the collective can recycle isolated machines to join other groups. To do this, each machine has a passport! Their passport stores facts about that machine, such as its level and machine type and the collective uses this to determine whether it will fit the requirements of another group, only moving across if it satisfies the groups needs.

Herd Example

Now let’s explore how herds operate and how group agents execute as players interact with them. Herds are typically placed into the world in a relaxed state where they’re not under threat and simply hanging out in a specific region of the map. Any given herd is typically a mixture of recon, acquisition and combat machines, with acquisition robots in the centre, whilst combat and recon patrol the outside to defend them.

When a herd is placed into the world, a collection of groups within that hierarchy request a role. This role assigns all machines it’s controlling with behaviours that reflect their purpose. This can include patrolling for threats, searching nearby disturbances, attacking enemies or simply scavenging resources in the world. These roles can shift as time passes and events force the herd to change its behaviour and structure. There is typically a limit on how many machines can fill a particular role within a herd such that their make-up isn’t unbalanced.

A machines role dictates the goals that the an individual agent will seek to complete. Hence with a relaxed herd, the acquisition machines will use the HTN planner and data stored within the group to find a local area to mine. Meanwhile recon and combat machines will generate patrol paths to follow. Patrol paths are auto-generated based on the local geometry, avoiding awkward terrain and – more importantly – avoids passing through long grass and other vegetation the player might use to stealthily approach the herd. However, in order to give players a fighting chance, many patrol paths will deiliberately pass close to stealth vegetation such that you can place traps or attempt to hack them more easily.

Herds rebalance their composition when under threat, forming ‘flee’ and ‘combat’ groups [from (Beij, 2017)]

But of course it doesn’t always stay this way; as players start to attack machines their behaviour will shift accordingly. For machines that aren’t part of herds, this comes down to the specific machine class. Only a few will actually run away when provoke directly, with the vast majority of machines attacking the player, with even acquisition machines often attacking the player if they’re on their own.

However, should the player attack a herd, the groups within hierarchy react in kind, but only if the herd has been alerted. As mentioned earlier, the group agent enables data to be shared between each machine, but it doesn’t update on every tick. As a result, the herds don’t have a hive intelligence and it is possible for the player to kill a machine without alerting the rest of that group. However, should this be spotted or if the machine under attack survives, it will notify the group that they’re under attack.

At this point, the hierarchy within the herd shifts, groups of machines within the herd request a new role and priority for execution of the corresponding behaviour. The group comprised of acquisition machines assume the flee r

Latest Jobs

Sucker Punch Productions

Bellevue, Washington
Combat Designer

Xbox Graphics

Redmond, Washington
Senior Software Engineer: GPU Compilers

Insomniac Games

Burbank, California
Systems Designer

Deep Silver Volition

Champaign, Illinois
Senior Environment Artist
More Jobs   


Register for a
Subscribe to
Follow us

Game Developer Account

Game Developer Newsletter


Register for a

Game Developer Account

Gain full access to resources (events, white paper, webinars, reports, etc)
Single sign-on to all Informa products

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