Welcome to part 5 of my series on the AI of Total War. In part 3 and 4 of this series I explored the pivotal changes made to the campaign starting in 2013's Total War: Rome II, followed by 2015's Total War: Attila. If you recall way back in part 1 of this series: the three key AI systems that drive the game are the unit, battle and campaign systems. Each of these are distinct from one another and handle distinct parts of the core game design. However, there are a significant number of subsystems that exist alongside or within these three segments that are critical to the games function. In part 4 of the series I talked about the diplomacy systems and how they largely operate, with some of the more recent innovations that arose in Total War: Attila. In this entry, I'm going to tackle a pretty important system one and I haven't got around to talking about yet the: siege battle system. Siege battles are large-scale attacks on fortified locations and structures that are critical to a players hold of a region in the campaign. While sieges have been in Total War in some form or another since the very beginning, I'm going to look at a more recent entry where the system was rebuilt to accommodate it's grander aspirations: Total War: Warhammer.
In its 10th major release, Total War moves away from history and into fantasy. More specifically Games Workshop's long running Warhammer Fantasy franchise. No longer tied to periods of human history, Total War: Warhammer offers a diverse and colourful cast of factions including the human faction the Empire, the Greenskin faction comprised of orc and goblins, Dwarfs and the Vampire Counts who command the undead. Not to mention the The Chaos faction and human Bretonnian faction also made available as DLC. Total War: Warhammer makes some big changes to combat: each faction has access to new hero units, special units such as giants, flying units and a spell system which can have impact both on the campaign map as well as the combat sequences. This is combined with a mixup in the makeup of each faction: each with a unique configuration of unit types and abilities. This really shakes up how a traditional Total War match might play out, given the Vampire Counts don't have access to ranged units, while the poor Dwarfs are too short to ride horses!
While these changes influence combat gameplay, a lot more was happening in how Total War manages sieges: massive battles as players attempt to capture or defend a walled city. Siege battles carry large stakes on the campaign, given if the attacking team are successful, it will allow them to assume control of a province on the map. While they've been a mainstay of Total War for several years now, Creative Assembly took the time to rebuild the AI systems for Warhammer not only to enable them to handle the new capabilities of factions, but also to make them more extensible and manageable.
A siege battle begins when the attacking player sends an army to attack the capital of a given province. Before actually beginning the siege battle however, they can take turns to build siege equipment such as catapults or siege towers to allow them to attack or mount the city walls. As battle commences, the attacking army is positioned just outside the city, with defending garrison forces and any reinforcement armies lying in wait either atop the city walls or on the streets. An attacking armies goal is to gain access to the city itself by either breaching the gates, mounting the walls or destroying them outright. Once inside, the attackers must push through and capture the victory point on the map: typically within the centre of the city.
Previous entries in the city, notably Total War: Rome II and Attila, focused on creating sieges that felt historically authentic: first bombarding cities to weaken or destroy defenses from all angles, prior to moving to attack. Even until recently, the implementation was a relatively simple single tactic control system governed by finite state machines, a topic I covered way back in my exploration of Batman: Arkham Asylum. But this time, the Warhammer team wanted to craft something that was fast, intense and largely focused on a single direction of attack. As a result, the system needed to learn how to execute numerous actions in parallel, as well as how best to utilise many of the new special tactics brought by the Warhammer IP.
But before we do this, let's take a peak at what the combat AI systems now look like, so as best to understand how the siege systems operate.
The Battle AI Model
Back in part 1 of this series, I talked about how Total War uses a main combat AI system for it's in-game battles. These systems implement behaviour akin to player decisions and move units of a given army around the battlefield to complete objectives. But how does the AI go from making a decision about an action all the way down to executing it? After all, the series is much more complicated now than it was before. The combat AI systems utilise what is known a Battle Model system as shown here. The focus of this system is to take a given alliance of one or more armies and break down a high level strategy into small and manageable tactics that can be sent to individual units. High level strategy is set by the Grand Tactical Analyser or GTA, that decides whether the entire alliance should attack or defend at a given point. This is then broken down into objectives that need to be executed to achieve a desired strategic outcome. Objectives are then passed down to a detachment of units and a tactic is then assigned to them to tell them exactly what action to make.
So when in combat, the key thing is what tactics are selected in order to achieve the objectives set by the Grand Tactical Analyser. In standard combat, we might be looking to advance in formation, to hold a position, to flank an opposing detachment. But when attacking in siege combat, it's broken down into three key tactics:
- Assaulting the city gates
- Scaling the city walls
- Breaching the city walls
There are also two additional tactics the Siege AI systems need to utilise:
- The Storm tactic: which is only achieved once a certain number of entry points are available in the city.
- The Reserves tactic: a special ability, in which the AI will not commit all of its forces to an attack at the beginning. Instead, it will hold units in reserve and observe the battle as it plays out. It will then absorb defeated or weakened attack units back into the reserves and deploy them to support other units or outright storm the city when the time is right.
If units successfully storm the city, then a separate sub system will kick in to handle their behaviour in order capture the settlement. Now how do each of these five major tactics work in the context of the game itself?
The AI Hint System
In order for the siege system to start selecting tactics, it needs to know what strategic opportunities are available to it. As such, each city has a set of key features exposed by level designers that the AI can assess in preparation for combat. It begins by getting a lay of the land, first by establishing the overall settlement perimeter and secondly by assigning deployment lines. The perimeter gives it an idea of where to attack and assigns deployment lines that will roughly align with it. This creates lanes for units to move from deployment line to city perimeter. The point where the lane meets the perimeter is known as the attack focus. The system then assesses each attack focus for three features:
- The number of dockable wall pieces near the focus, such that it may scale the perimeter.
- How close the focus is to a gate that can be attacked.
- How many destructible walls are near the focus.
Based on the scoring, the Detachment will assign either a Gate Assault, Wall Assault or Wall Breach tactic to a unit and assign that attack focus is their designated target. One caveat to all of this are the new flying enemies in Warhammer: these have one simple tactic and that's attack enemies on the walls of the city. For everyone else, all tactics attached to the focus points is aiming to establish an entry point: a focal point for future storm tactics, where the system switches from destroying the defences to taking the city. In the event the AI is successful in creating an entry point, the settlement perimeter is updated to recognise the new gaps that have been made which is used both by the attacking but also defending AI systems. All entry points are then maintained by a new Entry Points Manager that is attached to the Grand Tactical Analyser in the battle model.
So how does each faction execute a given tactic? It's actually kinda variable depending on what resources are available to them - be it the preparation of siege equipment or the make up of their attacking army. Each tactic calculates the estimated time to complete and percentage of completion at a given point, assigns units to a given tactic, with some intended to satisfy the objective and others to defend the objective-focussed units.
Each tactic will assign one or more units into an appropriate configuration and then if necessary move into range to conduct the attack. For example, wall assault will begin to move groups with either ladders or siege towers into range and add support units where possible, meanwhile wall breach tactics need to move into firing range, with cannons at front of the formation and catapults at the back. Meanwhile gate destruction tactics are set to have the most destructive and powerful units for that objective at the front, be it battering rams (which require infantry units) or monstrous creatures such as giants. During the assault, high value units such as monsters and heroes are evaluated for their value at that stage in combat, with specific usage flags set by designers that dictate how best to utilise them during a stage of the siege, even if it means keeping them behind and protecting them due to their high value.
Each tactic is then executed and observed to see how well it is progressing. Tactics are aimed at being modular but also can communicate with one another: meaning they can allocate units to one another if necessary. For example, when a gate assault tactic reaches the attack focus, it can relinquish units to a wall assault tactic and sometimes vice versa. In the event a tactic still falters, that's where the reserves come in. Any units that were not immediately assigned to a tactic at the start of the siege are assigned to the reserves. In addition, if it becomes clear that a tactic cannot be completed due to heavy defense and unexpected losses, the AI will reallocate the remainder of that unit to the reserves. The reserves then periodically assesses the active tactics to determine their strength and then deploys units in order to support them.
But over time the AI hopes to achieve a victory, once a suitable number of entry points are established, the system will execute the Storm tactic, where it forms storming groups of multiple units at specific entry points. In the event that units begin to break into the enemy settlement, that's where the secondary siege systems kick in.
Inside the City
Once inside, the settlement subsystem assumes control of any units that have crossed the settlement perimeter. It is then reliant on an established graph of the settlement: dictating how specific areas of the city are linked to one another. In addition, the settlement graph has an influence map overlay attached to it. This influence map carries a number of useful pieces of information at runtime, including the threat posed by a location, the strategic value of capturing or defending it, exposure to missile fire and any enemy occupation strength. This information when summed through the influence map gives a strong indication of whether a given unit could successfully assault and capture a location by building what is effectively multiple layers of useful strategic data into a information model. Think of it like a lasagne for destroying a city.
Total War continues to be an extensive and complicated problem space to work within. With each new release we see a need for more complex and robust AI subsystems, from unit movement, to combat, long-term strategy, diplomacy, siege battles and more. At the time of this video, Total War has released not only the sequel to Warhammer, but also announced two new titles: Total War: Three Kingdoms which will return the franchise to the real world with the Han dynasty of China, as well as Total War Saga: Thrones of Britannia - a new subseries focused on smaller and more specific periods of history. Even from its humble beginnings, Total War was aiming for high stakes and epic combat, but the challenge faced is far from easy.
As stated back in part 1 of this series, AI for real time strategy is one of the most complex and demanding out there. They might not get it right all the time, but it can't be denied that Creative Assembly put tremendous time and resource into continually expanding and improving the decision making systems from top to bottom as the franchise has continued to grow.
Siege Battle AI in Total War: Warhammer, Andre Arsenault, Creative Assembly, Game Developers Conference (GDC), 2017..