Sponsored By

Evolution of War | The AI of Total War (Part 2)

In my second article on the AI of Total War, I look at the rise of modding for AI behaviour, as well as the complete engine rewrite in 2009's Empire: Total War.

Tommy Thompson, Blogger

February 5, 2018

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

Welcome to part 2 of the AI of Total War. In part 1 of this series I looked at Creative Assembly's 2000 release Shogun: Total War - a game that redefined real time strategy games. Shogun defines three specific layers of AI systems: the unit AI that controls individual troops and keeps them in formation and on point, the combat AI that groups and sets formations to units and the campaign/diplomacy AI that conducts the turn-based strategy seeking to take control of feudal Japan. I concluded part 1 with 2002's Medieval: Total War: a game that refined and improved the core systems Shogun established. But this is just the beginning of a long journey improving and rebuilding the AI systems behind the franchise, both from within The Creative Assembly itself, but also from the Total War fanbase. So let's look at the subsequent releases in the franchise and watch the evolution of war take place.

Rome and the Rise of the Modding Community

2004's Rome: Total War brought both gameplay changes as well as a significant graphical overhaul. This third entry in the series brought a 3D diplomacy map as well as fully rendered 3D units to the franchise as it moved to 270BC Italy: the birth of the Roman empire. It's the entry that propelled the series from niche strategy sim to a full-blown blockbuster IP. However, it's also where some of the cracks were starting to show in the gameplay. This is most notable in the campaign segments, where the AI struggles to be as effective in this richer and more interesting set of diplomacy mechanics. In part this is can be attributed to the longer and more thoughtful progression of actions that are needed in order to build and scale your own corner of the Roman empire. As mentioned in part 1: the campaign AI is state-based and rather reactive in nature, meaning it isn't ideal when you need to consider long-term decision making, given these approaches seldom consider the history of actions previously taken and the long-term ramifications.

 

Despite these issues, it was still a valuable and fun entry in the series and one that has developed a very strong fan following. Rome is also the beginning of a long and storied history of mods being built for Total War. This was relatively easy for a modder to accomplish given that the earlier entries in the series left much of the data that drove gameplay exposed in the installation. As such modders could then build tools that manipulated that data for their own purposes. Many of these mods aim to improve graphics and controls, expand the narrative and create a richer world within which to play, such as Roma Surrectum and Rome: Total Realism. Some even take the core mechanics and AI and transpose it to other worlds, such as The Fourth Age - a Tolkien mod - and ironically, the Warhammer: Total War mod. Arguably the most impressive of these is DarthMod: the first in a series of mods by Nick Thomadis running from Rome: Total War all the way to Total War: Shogun 2 in 2011. DarthMod not only tweaks the presentation and gameplay, but often makes significant changes to the parameters that influence the underlying combat and campaign AI behaviours and gives more experienced players a run for their money: resulting in new combat formations, tweaked performance stats and more resilient and aggressive AI behaviour.

The underlying issues that arose courtesy of the revamp in Rome reached their peak with the release of Medieval II: Total War in 2006. Medieval II is in essence a revamp of Medieval: Total War in the Rome engine, but many of the underlying structural issues with the AI still held ground - but the thriving modding community largely made up for it. As such, it was time for a change, the AI systems needed to be rebuilt from the ground up, which is what happened with the release of Empire: Total War.

Empire AI

While Rome was the revamp aimed at refreshing the core systems and gameplay, 2009's Empire: Total War sought for loftier goals. A game aimed not only innovating on the core formula of Total War, but also to make it more accessible to a larger audience. This led to a refresh of the the UI systems, hints and tutorials as well as core components of gameplay. Battle introduced a large variation of units that were reliant on gunpowder weaponry, such as cavalry, musketeers, rifleman and heavy artillery and in conjunction with this, a loose cover-based and navigation system was introduced for troops, allowing them to quickly scale small pieces of terrain and take cover during heavy fire. The largest addition to Empire is the transition to real-time naval combat, where players take command of a fleet of ships and attack opposing forces. In addition, the core campaign takes place across a much larger domain: with the American continents, Europe and India all prominent locations, not to mention the sea lanes that connect them. To make things even more complicated, by this point the campaign AI now needs to consider army and naval resource management, spatial analysis of the game map, recognise enemy threats on different terrains and configurations, conduct diplomacy, manage and allocate its resources as well as work on construction, taxes and more.

Undoubtedly, this has led to a huge rise in the scope of the franchise and with it came aspirations for improvement of the underlying tech. Empire completely rewrote the Rome: Total War engine from the ground-up, resulting not only in a new suite of AI implementations at unit, combat and campaign level, but also some changes to how the game is delivered to users, which had a huge influence on the subsequent modding tools.

Empire: Total War rebuilt both the campaign and combat AI to migrate away from the purely reactive and state-driven behaviour: whereby the systems would largely respond in kind to decisions made by opposing players, but with their own flavour driven by specific configurations and parameters. For Empire the focus was on bringing the AI to a point it could consider more long-term ramifications as well as balance multiple objectives at once. This led to the adoption of the Goal Oriented Action Planning (GOAP) method: a technique popularised by First Encounter Assault Recon (F.E.A.R.) in 2005, and used in titles such as Fallout 3, S.T.A.L.K.E.R: Shadow of Chernobyl and Deus Ex: Human Revolution. GOAP is a method of classical planning: whereby agents use an abstract model of the world in order to make a series of decisions that will transform the world to a desired outcome. It's ideal for situations where we have a number of individual actions in a sequence that we wish to complete and can reason amount multiple objectives at the same time and execute actions accordingly to address them, provided they do not conflict with one another. Many of the original tactics from Shogun could transfer here quite easily, given that the Art of War logic could easily be encoded into a planning-style language for search and execution. If you want to know more about AI planning and how it works, be sure to check out my case study on F.E.A.R. and Goal Oriented Action Planning, as well as the use of both GOAP and Hierarchical Task Network planning in High Moon Studio's Transformers games.

One of the biggest aspects of this release came from how the AI is modelled within the game itself. In Rome: Total War - the game AI was mashed within the logic of the game itself. Meaning it was part of the game and could potentially be capable of doing things that players could not or have access to information it shouldn't. In this and future instalments, the campaign AI is separated such that it now actively plays the game like a human does, with interface hooks in the code base that allow for it to talk to the game and vice versa.

The campaign AI is driven by considering three key questions:

  • How well am I doing right now?

  • What can I do next?

  • What resources can I allocate to that?

These three questions allow for the use of a Belief Desire Intention or BDI system. Meaning that the campaign AI models a set of beliefs, desires and intentions that drive its decision making processes. Beliefs give an understanding of the world to the AI player, but with the proviso that they might not actually be true, such as where enemy resources are or their relation with a another faction. The desires represent the motivational drive of the player and will set the goals of what the system wants to achieve, both immediate and long-term. This can include things such as capturing or defending territory, stopping enemy agents, recruiting armies, prioritising construction or conducting diplomacy with neighbouring factions. This last one is super complicated, I'm going to come back and talk about it in more detail in a future video in this series. Lastly, the intentions represent the deliberative state of the agent: meaning once it has chosen to do something, these intentions are set for it to continue to achieve, even if it gets sidetracked prior to completing them. This works within a planning-based system given it can continue to monitor unresolved goals and try and work towards them while planning to resolve immediate concerns. However, as will be discussed in part 3 of this series, the system was incapable of considering many of the overlaps that occur with some of these actions and the conflicts they create in the systems own internal decision making, lead ing to another campaign AI upgrade a few years later.

In combat the AI systems carry a number of goals that allow them to be more effective in not only completing their mission, but looking after their own resources. So while an active combat goal may be to attack a given unit up ahead but it may also have a goal to ensure its right flanks is secured given the position of the opposing force. These two goals would be re-balanced and prioritised depending on what was happening in the game at that time: with the current size and positioning of its own army, the current actions its executing, the enemy terrain and what an assessment of the opposing enemy being taken into consideration. While goals looking towards attacking the enemy may change or be removed once completed, the defensive goals would continually shift based on the current situation and all of these goals are prioritised by the current state of the battlefield. This results in a system that even when a current plan of execution is interrupted due to shifting priorities (perhaps in a brief effort to defend itself by manoeuvring, or it may need to save its general from a flanking attack), it will ultimately be able to go back to the original goal and resume from where it was before provided it can resolve them. Conversely, if the AI is attacking the player, it won't make reckless decisions - such as breaking its artillery off from the wide flanks in order to attack a different target than the main army - if it's going to pose a significant threat to the survival of the rest of its forces.

Empire: Total War was released in February in 2009 but sadly to mixed results. At launch both the campaign and battle AI struggled under the weight of the problems it faced. This isn't terribly surprising: planning for large-scale problems of this nature is incredibly taxing and there is only so many possible outcomes or situations that developers can anticipate during the testing. As Creative Assembly creative director Mike Simpson stated:

"This AI is not like any other we have written... [It's] by far the most complex code edifice I’ve ever seen in a game. I wrote much of the campaign AI for Shogun and Medieval I (Ah… those were the days…) and I know that even quite simple “static” evaluate-act AI’s with no plans or memory can be complex enough to exhibit chaotic behaviour (we’re talking about mathematical “butterfly effect” style chaos here). It does what it does, and it’s not quite what you intended. This can be a good thing – you cull out the bad behaviours and are left with just what is good, and with a simple system that’s not too predictable.

"...The Empire AI is way more complicated than any of our previous product... The net result is an AI that plans furiously and brilliantly and long term, but disagrees with itself chronically and often ends up paralysed by indecision."

[Blog the Second, Mike Simpson, Total War Blog, October 9th, 2009]

Creative Assembly attacked this problem consistently for six months after launch, patching the AI up until version 1.5 of the game. These improvements were transferred across to 2010's Napoleon: Total War, which was in many respects a functionally identical game taking place in a different combat theatre. This was in part due to the fact that the campaign and battle AI teams were constantly going back to fix problems in Empire while Napoleon was in development. Hence there are only small changes and improvements in the next release.

Modding

Meanwhile the modding for Empire hit something of a stumbling block given the change of engine. In previous entries, Total War shipped with many of the underlying variables and performance settings as external data and was loaded into the game on starting up, making it relatively easy for mod tools to be built that could expose and customise it. While ideal perhaps in the days of Shogun, this was simply unsustainable as the size and scope of each game increased: with increased campaign maps as well as more and more tactical combat affordances. It's been quoted that the increased amount of data, combined with expected memory limits of players computers, resulted in significant performance bottlenecks prior to launch. As such, much of the data was pre-processed and compiled into the final executable, which denied modders access to a lot of underlying architecture.

This didn't stop mods from arising however, with the ever popular DarthMod returning once again for Empire - modifying the underlying parameters to tweak the AI into being more resilient, as well as Bran's Empire AI submod which takes the DarthMod and tweaks it further to reduce some of the more awkward decisions being made in the game.

This difficulties in developing these mods eventually led to a greater effort by Creative Assembly to enable modders to access the backend of the later versions of the game, with more ample mod support in Total War: Shogun 2 as well as adoption of the Steam Workshop API's in many subsequent releases.

Closing

The evolution of war brought many a growing pain alongside it, but in many respects led to a smarter and more engaging experience for players over time. As players have craved greater authenticity and control of this experience, this too had led to the rise of the modding community that is still strong in the Total War franchise to this day across numerous entries in the series. I hope you've enjoyed this second entry in my series on the AI of Total War. In part 3 I'm taking a look at once of the most critical yet controversial games in the series: 2013's Total War: Rome II. A game that brought some groundbreaking AI innovations under the hood and helped redefine the types of AI systems that can appear in AAA videogame development.

Read more about:

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

You May Also Like