This article is an edited transcript of the AI and Games video linked to above.
Some of the biggest challenges facing modern game development can be found in open-world game design: how to build large, vibrant and interesting locales for players to explore. Artificial intelligence can often by adopted to address this challenge by creating interesting and dynamic environments that enhance the overall experience for the player. In this article, we take a look at the methods and design decisions behind the ever increasing game worlds in Ubisoft’s Far Cry series.
Far Cry is renowned for an open approach towards problem solving: allowing players to explore the world in a manner that suits them. Originally starting out as an open — albeit linear — gameplay experience, the series has became increasingly more adventurous in its design; with maps not only increasing in size but also with the introduction of more interactive environments and wildlife. The latter proves really exciting, given that it can completely change the dynamic of gameplay — which could prove inspirational or even fatal when you’re in the thick of the action.
However, achieving this level of engagement and interaction can be rather demanding: given designers need to balance the players sense of importance and agency, while ensuring they’re not bludgeoned repeatedly and offered some respite. Similarly, there’s also the implementation issues faced in managing open world assets: given it’s not computationally feasible nor responsible to leave thousands of non-player characters roaming the Rook Islands or the vast mountain ranges of Kyrat.
So how does it all work? The answer of course, is with a little bit of AI ingenuity through smart directors. This is an increasingly popular way to manage large open-world environments, with much of it stemming from the pioneering works found in Left 4 Dead. Turtle Rock and Valve’s survival shooter focused on the distribution of enemy characters within close proximity of the player and Far Cry follows suit. So let’s look at the design tricks behind their AI implementation.
The Far Cry Recipe
The original Far Cry launched back in 2004 is an action heavy first-person shooter that gave the illusion of open-world gameplay through its large albeit limited areas and maps. Meanwhile, 2008's Far Cry 2 was the first in the series to truly embrace the notions of open world play and more importantly, systemic design: the ability to have a range of independent systems and mechanics that can be combined in fun and interesting ways. The opposing human factions, reactive and aggressive wildlife, combined with vehicles, environmental effects and more are intended to for players to exploit for their own personal gains. But it didn’t quite pan out: Far Cry 2 is a bit of a frustrating experience, largely because these systems were not properly balanced or constrained.
However continued development of these systems lead to their adoption in 2012’s Far Cry 3, where they had reached a level of maturity that improved the experience overall. The systemic framework in Far Cry 3 achieves what Ubisoft themselves refer to as “The Anecdote Factory”: a system that would create weird, wonderful and individual gameplay experiences you would talk about with you friends. This could range from unexpected tiger attacks to luring tigers from nearby jungle growth into enemy bases whilst flying a small gyro-copter and dropping C4 explosives.
Meanwhile 2014’s Far Cry 4 attempted to improve upon what Far Cry 3 achieved while also addressing some of its criticisms: notably the balance of this systemic framework operating in and around a linear narrative.
The vast majority of this systemic framework is reliant upon non-player character (NPC) AI: ranging from the enemies, to the civilians, to allied fighters to the animals that prowl the open-world maps. It just needs to know where and when to put them in the world.
The Encounter System
The scale of the world of Far Cry 3 is very impressive: with the Rook Islands of the estimated to be around 300 square miles in size. That’s a lot of ground to cover, and given you would need thousands of non-player characters within that space to make it interesting, you suddenly have a difficult design problem to solve. Not just in ensuring characters are in locations that present interesting opportunities for players to explore, but how best to manage these characters in a resource constrained piece of software.
This leads us to Far Cry’s dirty little secret: that at any point in time, the game is only maintaining active non-player characters within less than 500 metres of the player, with enemy characters and animals being added and removed to the world as the player moves around. This is actually quite pragmatic, given that leaving large numbers of characters in the game at once is highly expensive: wasting not just memory needed to store these NPCs, but potentially CPU cycles to continually update the state of these characters during play. The game isn’t interested in managing hypothetical situations such as a tiger attacking a gazelle 3 miles north west of the player. The resulting encounter system of Far Cry 3 and 4 operates on a simple principle: if the player didn’t see it, it didn’t happen.
The NPCs within the game are designed to react and behave in a context-driven fashion: to attack, evade or explore areas of the map based on what’s happening around them. This is driven by finite state machines (FSMs), a topic we’ve covered at length in our videos on First Encounter Assault Recon (F.E.A.R.) and Batman: Arkham Asylum. Many of these NPCs, be they enemies, civilians or animals, are designed to react to nearby stimuli in an appropriate fashion. Their responses are reliant upon a rich navigation mesh that is embedded into the game world, with smart object nodes placed in areas of interest that can trigger specific animations. While they know how to react intelligently, it does not factor whether any other non-player characters are in proximity. In fact, enemy NPCs are rather limited tactically, which becomes more apparent when you play the likes of Far Cry 4 in the online cooperative mode. Despite this, they’re still a cracking shot and a separate damage director system manages their shooting capabilities based on the number of NPCs in the scene. Thus ensuring you don’t get killed by six headshots at once from 100 metres away.
In order to maintain decent performance - given that these games not only have to run efficiently on PC but also between console generations — the director AI enforces constraints on the number of systemic elements that are active at any point in time. This includes the number of enemy NPCs, but also animals and items such as vehicles given the additional computational load they bring with them. In fact, in Far Cry 3 the numbers are really limited: with only 12 NPCs max in the world at once and up to 20 animals, with vehicles also limited to around 2 or 3 types at any point in time. The relevance of these characters are measured frequently: with the director moving or deleting characters if it’s apparent they’re too far away and won’t ever catch you. If you’re running in a particular direction, the system will spawn enemies in front of you: factoring not only your heading but your current speed: thus ensuring they don’t pop-up in front of you.
This system was enhanced for Far Cry 4 to become to create more interesting and varied events. Placing the NPCs in the world is one thing, but placing them in specific configurations related to one another can result in the player becoming involved in more engaging experiences. As such, Far Cry 4 introduced a dynamic encounter method that procedurally generates events within proximity of the player: such as enemy NPCs in combat against Kyrat’s wildlife. This pays attention to your current objectives, sometimes putting them in the way, or focusses on completed tasks, like having a recently captured output come under attack again by the local militia.
The use of dynamic director systems has become increasingly popular for open-world game environments: with titles such as Saint’s Row IV, Titanfall and The Witcher III: Wild Hunt all adopting these in some fashion or another, with their own unique design problems to solve. But this isn’t the only innovations that the Far Cry series continues to make, with the more recent entry Far Cry: Primal, introducing companion AI in the form of tamed animals. This is in fact an extension of the AI system used for the tiger companion in the Shangri La sequence of Far Cry 4. We’ll be returning at a later date to talk all about how that works and the design problems Ubisoft’s developers overcame to make it a reality.