Behind The AI of Horizon Zero Dawn (Part 1)

Jan. 31, 2019
protect
<iframe title="Embedded content" src="//www.youtube.com/embed/XxuSFBVQULY?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="900910307" data-gtm-yt-inspected-91172384_165="true" data-gtm-yt-inspected-113="true"></iframe>

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.

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