Sponsored By

Building a Pirate's Paradise: The AI of Sea of Thieves (Part 1)

In this first of a four-part series, I explore the numerous AI systems running under the hood of Rare's online pirate adventure game and the work required to maintain the experience for players across the Sea of Thieves.

Tommy Thompson, Blogger

June 4, 2019

12 Min Read
Game Developer logo in a gray background | Game Developer

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.

'The AI of Sea of Thieves' is released in association with the UKIE's '30 Years of Play' programme: celebrating the past, present and future of the UK interactive entertainment industry. Visit their website for links to interviews, videos, podcasts and events.

If you’ve followed this series either here or on YouTube, you’ll know that I explore how AI is built in commercial video games but this occurs long after the projects completion. I’ve never had the opportunity to talk to a studio more candidly about their experiences and the path their work has taken from initial concept to being on store shelves and surviving in the modern gaming ecosystem. However in late 2018, I was invited to the offices of Rare: developers of online pirate adventure game ‘Sea of Thieves‘.  It’s a game that not only brought a unique experience to the Xbox platform, but also helped redefine the studios identity. Join me as I go behind the scenes with some of the programming team responsible for Sea of Thieves and learn first-hand not only how the game was built, but the ongoing dedication and craft as it sees continued updates and improvements today.

About Sea of Thieves

Rare is one of the longest-serving companies in the British games industry and has survived for over 30 years by evolving and adapting to the changes in the market: first developing titles on the ZX Spectrum, to forging a strong partnership with Nintendo in the 1990’s and now as one of Microsoft’s internal studios supporting the Xbox brand. In 2015 – following the release of three titles in the Kinect Sports series and the anniversary collection Rare Replay, the studio had focussed its efforts on something completely different – a project that would challenge not just the types of games they made at the studio, but how they were going to make them as well.

Sea of Thieves is derived from a desire to do something unique. Whilst Rare sought to move towards creating a live service game – something they had never done before – its design was intended to be player centric. Players can tackle missions from different quest-givers at their own pace, allowing you to prioritise the experiences you enjoy the most and keep the game as accessible as possible. In return, players not only increase their standing with different factions, but earn currency to acquire a variety of new cosmetics: a cool new hat or peg leg, a nice top sail for your ship, or a gold trimmed water bucket. Through this approach, players can derive their own satisfaction from achieving tasks in the game, from attacking skeleton forts to sailing through storms and playing sea shanties with strangers – along with a tankard of grogg or two.

Over time, Sea of Thieves has developed a dedicated fan base that continues to sail the seas for adventures that can challenge even the most ardent of Pirate Legends. Much of this is thanks to Rare’s continued development of the game, with four major updates within eight months after the games release. Meanwhile April’s anniversary update kickstarts the 2019 content drops as Rare supports the game for the foreseeable future, with the introduction of PvP mode The Arena, the new Tall Tales storyline as well as new gameplay mechanics. These new features, combined with continued refinement of existing ones, seeks to mix things up in new and interesting ways that adds new layers of complexity to the core gameplay.

The game has a variety of AI systems under the hood that continues to increase with each update. While the game launched with traditional humanoid enemies such as the skeletons as well as ambient AI on islands such as snakes and pigs the game has focussed on the expanding its roster of sea-based threats that can threaten you and your ship. Not content with sharks at launch, 2018 saw the addition of the kraken, the megalodon and haunted galleons with each continuing to change and evolve with each new expansion. All of this requires systems that balance that experience: ensuring this online world with hundreds of AI characters is stable and manageable as pirate crews sail the seas and get up to all sorts of shenanigans on each server. Plus by virtue of it being a live service game, the project needs to be maintained in a manner that it can be iterated upon quickly, allowing for new content to be released frequently and ensures the game continues to be stable for players. All the while achieving this without overworking the development team – and AI even has a part to play there too. But before any of that can come into play, let’s consider it’s earliest beginnings and how Sea of Thieves was built.

Building AI Systems

Having been invited to Rare’s offices I was keen to learn as much as I could not just about the AI behind the game, but how it all came to be in the first place. Sea of Thieves is built in Epic’s Unreal Engine 4, which is of course not just one of the most popular commercial video game engines, but one that has a strong reputation within the AAA industry.

Unreal is known for being a reliable engine both for networked gameplay and cross-platform development – which was critical given the intention to launch the game on both Xbox One and PC and connected into the Xbox Live ecosystem. In addition, UE4 arguably has the most robust set of AI tools available in a commercial engine for developers to work with. Not only does it provide a suite of navigation mesh tools – which ensures characters can move across surfaces and recognise changes in terrain – it also has the behaviour tree system for creating versatile behaviours that are responsive to in-game events. Plus whilst still in an experimental stage when Sea of Thieves started production, the environmental query system (or EQS) can simulate sensory inputs and minimise performance overheads for checking whether characters can be seen or heard in proximity. However, that still wasn’t enough for what Rare had in mind. Given, as we’ll see throughout these videos, only the skeletons and other land-based AI such as pigs and chickens are built entirely using the original AI frameworks – with a bit of Rare’s own special spices of course.

A big reason for this is that the game largely takes place in-water, either swimming around or in rowboats and ships, and navigation meshes don’t support that – a point I’ll come back to later. Fortunately, UE4 provides access to the engines source code. This enabled the developers to build their own custom water navigation system and then hook it into the existing navigation framework of the engine, a point I’ll return to in part 2 when we look at the shark AI. Plus as we’ll see in part 3, enemies such as the kraken and haunted ships required bespoke tools that would enable the AI to behave in a way that simply isn’t possible in UE4 by default. So once again Rare were able to create unique systems that fit into the existing Unreal Engine AI workflow, and ensure the toolchain doesn’t become too unwieldy to manage.

Fitting AI around Mission Design

As the time of writing, Sea of Thieves is now one year old – having been released on March 20th 2018 – and during this first year, the game carried three main activities for players to participate in. Each of these activities have their own requirements and dependencies in terms of gameplay, mission construction and AI behaviours where necessary. Non-player characters based at outputs allowed for you to collect missions from one of the tree main trading companies:

  • The Gold Hoarders: Where you travel to specific islands and dig up buried treasure.

  • The Merchant Alliance: that asks players to acquire specific items – be it animals such as pigs and chickens or cargo runs of rum and plants – and deliver them to islands across the open world.

  • The Order of Souls: where you need to go one or more tropical locales, find undead skeleton warriors, kill them all over again and then sell their skulls for gold.

In each instance, these missions require gameplay systems to generate AI characters at runtime to facilitate the missions requirements. For example Order of Souls missions require skeletons to spawn onto specific islands for the player to fight against, but also the specific high-value targets you need to take out. Meanwhile in Gold Hoards and Merchant Alliance quests, skeleton warriors will still appear on islands at specific times in order to present a challenge and get in the way between and your loot. Plus in Merchant Alliance quests where animals need to be captured, the game needs to make sure animals are going to spawn in for you on certain regions of a given island for you to capture them. This has since been embellished with the recent anniversary update which introduced a fourth trading company – Hunter’s Call – that introduced fishing mechanics – and new fish AI to go along with it.

With a mission in play, the game not only needs to ensure these characters are spawning in, but they’re balanced in terms of number and difficulty based on the size of the players crew, the location the mission will take place in, the ranking of the player who acquired the mission from the Trading Company, as well as the mission type itself. That’s where a little bit of procedural generation comes into play.

The bounties – how many enemies and captains there are – are constrained within a set of parameters.  With each mission being generated at purchase time.  So when you spend the in-game gold it will decide where in the game world you visit and how many targets you need to take out.  Each individual bounty is based around specific targets within certain regions of each island.  These are then balanced out such that if you have multiple bounty targets they will each provide a unique tactical combat experience.  For example, you may have one fight you on the shoreline whilst the other is deep in a cave.

Over time, each of these mission types scale in their own unique ways, providing an ever increasing challenge not just for players but designers too!  Each of these mission strands scale independently from one another, allowing players to prioritise quest lines they prefer and not to be punished or left confused when picking up missions from other Trading Companies. Hence you can decide after hours of playing through the Order of Souls to do a quick run for the Merchant Alliance but the scale and difficulty of that subsequent mission won’t be influenced by your preceding hours of play.

But this presents a much bigger problem for AI performance and networking: given your crew isn’t the only one on a given server. This is similar to the challenges raised when I looked at the AI of Tom Clancy’s The Division, where the game had to balance all the AI behaviours happening out in the active world. How do you maintain the performance of the game world with all these AI characters running around? It was a big topic that we discussed at length in the studio and while the exact maths involved is still a secret, what I did learn is that the AI characters for each mission are only spawning in when necessary and not wasting CPU and memory resource by running around on an island that is miles away from the nearest player, or sailing the seas where nobody is going to notice them.
This process helps ensure that while one crew might be busy hunting a Megalodon, it doesn’t impact another the crew on an island completing an Order of Souls mission. AI characters such as pigs and chickens don’t spawn on islands until crews are close enough that they might actually see them. But in addition, pigs, snakes and skeletons on the same island as players often go dormant when not in combat and beyond the line of sight of any human player. It’s a safe tactic to employ that minimises unnecessary computation on server-side, given nobody is going to notice what happens to these characters anyway, freeing up server resources that could be put to better use elsewhere.

As we’ll see in the upcoming episodes, this philosophy holds true for the likes of the skeleton galleons, the megalodon and the kraken. However, the rules of these systems are unique in each instance and run on completely separate services and behaviour systems.

Closing

Bringing this swash-buckling adventure to players already sounds likes a daunting task, but this is just the beginning and I still have a lot of exciting topics to cover. Here’s just a taste of what’s still to come…

  • The behaviour tree architecture of the skeletons AI and how they’re built to use the same controls as humans.

  • How sharks required a completely different navigation system at launch.

  • The deadliest threats looming deep under the sea: Megan, Karen and… Skevin??

  • And finally we’re going to look at the automated testing framework that enable Rare to extensively test the game during development, minimise errors and enable faster and more streamlined deployment of the game both before and after launch.

Read more about:

Featured Blogs
Daily news, dev blogs, and stories from Game Developer straight to your inbox

You May Also Like