Road to War: Total War Series AI

Original author: Tommy Thompson
  • Transfer
image

Since the founding of my AI and Games video series on YouTube, I have been exploring various AI implementations that solve specific tasks in video game design that require immediate, responsive behavior combined with long-term and strategic decision making. A popular genre in which AI can create fast, responsive, and addictive gameplay is first-person shooter (FPS). But if we want to consider the need for effective systems that take into account the balance of short-term and long-term decisions, then the games in the genre of real-time strategy (RTS) are an ideal subject to study.

Both RTS and FPS continue to innovate modern video games in an effort to match their design. But games in the RTS genre need to appreciate the much more extensive and lasting impact of quick and responsive decisions. In addition, they need to manage resources at different levels of abstraction and complexity in hours of gaming sessions. When discussing the complexities and innovations that the AI ​​of strategic games have to deal with, one cannot fail to mention one franchise - Creative Assembly's Total War .

Since the release of the first part of Total WarIn 2000, the franchise was constantly growing and gaining power. Each game became more and more ambitious, and the problems that the AI ​​system had to deal with continued to increase in scale and complexity. As a result, the company assembled a development team that, like no other in the history of video games, is developing new trends in the creation of artificial intelligence. However, the path to the last parts of the series, such as Total War: Attila and Warhammerwas not smooth. Therefore, in this article I will consider not only the fundamental principles of the Total War AI series, but also how each new part of the series has improved, corrected or completely rewritten parts of these systems. In addition, I’ll talk about the reaction of fans of the series to these changes, about the modder community that has expanded in the framework of Total War, as well as how Creative Assembly from the very first game of the series to this day has applied advanced scientific discoveries to create innovations.

RTS games and AI


But first, let's take a look at the Real-Time Strategy genre itself to see how Total War takes its place. The main objective in real-time strategies is usually control over territories and resources: two or more opposing parties appear on the same map to capture dominance, protecting resources or locations in a limited area. Often, to achieve these goals, each side builds buildings and units that either improve the collection of resources in a given area, or protect existing buildings and lands, or explore and capture other areas of the map by force. In the process of solving the latter problem, destruction of enemy units is required. For this process, the player usually needs to explore areas previously hidden by the fog of war to locate enemies and resources. Moreover,


Although Westwood Dune II: The Building of a Dynasty, released in 1992, was not the first RTS game, it became an archetype for future games of this genre, such as the Command and Conquer series of the same Westwood, Age of Empires , Total Annihilation , Dungeon Keeper , Homeworld , and Blizzard's Warcraft and Starcraft franchises . The genre has continued to evolve and create offshoots since the late 1990s. Similarities arose, for example, the genre of real-time tactics represented by the games Dawn of War and Star Wars: Empire at War, in which the emphasis was on tactics, rather than resource management. Meanwhile, games likeUFO: Enemy Unknown (1994) investigated the balance between real-time and turn-based decision making. Her approach turned out to be popular, which proves the successful restart of the franchise called XCOM: Enemy Unknown in 2012. One of the most deviated from RTS games was the Multiplayer Online Battle Arena, or MOBA, popularized by Defense of the Ancients mod for Warcraft III and consolidated its success thanks to Dota 2 and League of Legends . In them, players take on the role of ground-based hero units that determine large-scale strategies and implement them during the match.


AI has been used in RTS since the very beginning of the genre: the players who controlled the movement of units simply indicated to them where to go, but did not pave the way on their own. Therefore, the player had to interact with such systems in order to obtain the desired results. In addition, AI is critical for single-player game modes in which the player fights against enemy commanders controlling their own units and production strategies. The role of AI in such games is extremely complex and is considered one of the most enormous problems that have been encountered in scientific research. This led to the creation of many scientific assessment tools and projects, including the Starcraft AI Competition, held at the AAAI conference on artificial intelligence and interactive digital entertainment.

Total war


So what makes Total War so special and complex for AI systems? The Creative Assembly series of strategic games is interesting in that it combines several modes of strategic gameplay: players in a step-by-step mode manage resources and policies, and also participate in large-scale real-time battles. In addition, the battle is fought at the micro and macro levels, requiring the AI ​​not only to control individual units, but also to more abstract control over the types of troops, control combat structures and the deployment of troops on the battlefield in real time.

The first part of the franchise, Shogun: Total War, balances between a simulation of a battle striving for realism and persuasiveness, and a political strategy that gives each conflict a context and understanding of what is at stake. The first Total War takes place in 1530, during the Sengoku period of feudal Japan: this time was popularized in modern culture by the works of Japanese film director Akira Kurosawa. Films like Shadow of a Warrior , Seven Samurai, and Raninfluenced the design and development of the project. Excerpts from Ran were even used in the game’s videos. The player and the enemy AI take on the role of daimyo, the feudal rulers who govern the provinces of Japan. They have to conduct both diplomatic games and military operations. When opponents are drawn into conflict, players take control of the taisho (generals) and move hundreds, if not thousands, of soldiers across the battlefield. The Sengoku period was an ideal historical era for the game, because the politics and even the economy of that time were based on the logistics of the armies that defended the daimyo and its ambitions.


Total War differs from many traditional real-time strategies in that it abandoned the mechanics of the fog of war as well as resource management in the warhead. Due to the structure of the game itself, the control of the opponents of the AI ​​was divided into two separate AI systems:

  • Campaign and diplomacy AI manages the turn-based strategy of the game and is responsible for moving armies on the map, is engaged in diplomacy (sends killers or negotiators to eliminate opponents or form alliances), and also takes care of agriculture and the infrastructure of its own provinces.
  • Combat AI commands combat units, strategy, and attack patterns. Like live players, he is only responsible for managing the strategy of individual groups of units, because the individual units themselves are also controlled by their own AI .

Therefore, in order to deal with Total War AI, I will explore AI systems from the lowest to the highest levels: from individual squad management systems to strategic systems whose task is to conquer all feudal Japan.



Unit AI behavior


The battle in Total is carried out by units: groups of certain types of troops that can be assigned combat formations, from melee units to archers and cavalry. Such combat units not only must maintain their formation, but also move, and also conduct the battle as a single unit. Movement is often challenging, especially when a unit is ordered to go through different types of terrain, such as mountains and forests.


Standard neural

network scheme Neural networks operate as a weighted function of summing incoming data. By changing the weights of each individual computing node, or “neuron,” we can change the result of the data transferred to the layers on the right. [Image source]


To achieve this, Total War uses artificial neural networks to control individual units. Neural networks are a fast and effective tool for achieving fast and reactive responses to a predetermined task. A neural network processes data in “neurons”: simple processing nodes that receive incoming data through weighted “synapses”. By changing their weights, we change the results of data transmitted over the neural network. Usually these weights are selected using machine learning methods, but they can also be adjusted manually if the network is small enough. They are effective because after training, the processing time for making a decision is incredibly short. In addition, a well-trained neural network is able to generalize its decision-making process,

Despite this, neural networks are usually not very good when they are required to simultaneously perform several tasks, especially when these tasks contradict each other. For this case, the units have different neural networks, which they can include depending on the task being solved: choosing a construction, avoiding enemy fire or selecting a position for an attack near or far. Each of these networks was created in advance, it is not configured and optimized during the game, that is, it does not learn to become better during the game. Such systems of AI units work regardless of who controls the army - man or AI, because the player in any case needs such systems of neural networks to control the behavior of individual units.

Combat AI behavior


The battle level is an AI system that controls the opponents of a player. This AI makes decisions about the choice of building groups and the actions of units. He mutually moves parts of the army to achieve a certain tactical or micromanagement movement of units depending on the current terrain or weather.


To achieve this, Shogun employs a logical system that allows you to make certain decisions based on the current state of the world. Such decisions are taken from the Art of War : a collection of strategies by the Chinese military strategist Sun Tzu, dated about 500 BC. Using a logical system is well suited for adapting texts; in many cases, the specified conditions are used to obtain a certain response from the system. These rules take into account the type, condition and size of their own units and opponents, the current terrain, weather and morale of the troops. Here are some of the examples taken from The Art of War:

  • If you are surrounding an enemy army, leave one side open.
  • In open areas, do not try to block the enemy’s path.
  • If you have ten times more strength than your opponent, surround him on all sides.
  • If you have five times more strength, attack him.
  • If you have twice as much strength, divide it into parts.

The developers say that in the combat AI system, 220 rules are implemented in three different versions, each of which has slightly different sets of behaviors. The most important reason for this was the creation of the most realistic battle possible, unlike the tactics that controlled most of the real-time strategies of that era. Here's what Creative Assembly Development Director Mike Simpson says:

“Most games use simple template behavior scripts that fire on contact and very simple crowd behavior for units. They are very limited and seem to be “toys” rather than real. I mean, the tactics used to defeat them need to be studied in every new game, and sometimes in every scenario
or level, and it has nothing to do with reality. We sought to create a game in which real tactics from the real world will work. “We did not choose the easiest way, but it brought a big reward.”


[ Battle AI , Mike Simpson, Total War Blog, November 10, 2009]

AI Campaign Behavior


The final layer of Shogun AI systems is a campaign and diplomacy system. She manages all the decisions on the main map of the campaign: managing the movement of armies, conducting diplomacy between the parties and building the infrastructure of the provinces.


It uses a combination of classical decision making on finite state machines with genetic algorithms to create individual tactics for each daimyo. A simple state-action system simply indicates what needs to be done under current conditions and provides an instant AI response. It does not store any memory of existing behavior and does not have a complex decision-making process. She simply reacts to events around. Then a genetic algorithm is used to provide some personality.

Genetic algorithms are a type of machine learning in which we create huge quantities of possible solutions to a particular problem, which learn to solve it by growing the best. These possible solutions are not program code, it is just an encoding of how the AI ​​usually behaves in the form of a string of numbers, which is then passed to the AI ​​itself to specify its behavior. They allow us to create sets of complex solutions to the problem: they all do not act similarly to each other and have their own slightly different characteristics. As a result, each daimyo received its own unique behavior in battle. From the players' point of view, this gives them a certain personality: some daimyo tend to diplomacy, others are more aggressive and expand their territory, attacking other AI rulers and the player.

Medieval: Total War


All three of these systems are fundamental principles of the Total War AI: they control individual units, providing convincing behavior, group troops in a logical, reactive and difficult way for players, and also create strategic opponents with their own personality. Despite the fact that the first game was created back in 2000, the basic principles of battle and strategy, combined with the systems created in Shogun, were transferred by the Total War franchise to various new battlefields of the many subsequent parts of the game. Despite all these behind-the-scenes innovations, AI still cannot be called infallible, and in each new version of the game it improves and grows up.

The first changes were made when the series was transferred from feudal Japan to the European Middle Ages. Released in 2002Medieval: Total War sends the player even deeper back in time, towards the end of the eighth century, and leads him until the fourteenth century. Players control various parties in different historical periods: from the Viking era in Britain, when most of the country was fragmented due to the Roman Empire that left it, to the late Middle Ages, when the borders of countries of most of Europe took shape.

Medieval: Total War in many ways has become an improved variation of the first game. It is built on an improved version of the Shogun engine, which allowed for even larger battles. The biggest differences in AI technology between Shogun and Medievalthere was only a lot of optimizations and fixes. Unit AI systems have learned to deal better with clusters in tight spots, such as bridges. In addition, the range of combat AI systems has expanded from three to nine, providing more flexibility. All this resulted in the creation of a game that Rock Paper Shotgun called "almost perfect." Rob Zackney wrote:

“I’m still not sure that in the Total War series it will be possible to create an even more balanced game. AI easily controls troops on the map, and the different starting positions of each kingdom and empire allow the formation of real AI superpowers, which later will cause the player a lot of trouble.

Medieval is a triumph of simplicity, and Total War took another ten years to get closer to it again. "

[ The Best And Worst Total War Games , Rob Zackney, January 4, 2016]

Finally


Shogun and Medieval were the very beginning of the franchise and it can be said without a doubt that the road to war was not smooth. With each subsequent version of the franchise, the complexity grew in scale, and the volume of the games themselves increased significantly. In the second part of the article, I will talk about the modders community that developed after the 2004 release of Rome: Total War , how the release of Medieval II: Total War encouraged developers to rewrite and rebuild in Empire: Total War , and how it a massive change affected the entire franchise until the release of Total War: Shogun 2 .

Also popular now: