Dev Blog 25/10/18


 
Greetings warriors of Calradia!
 
Artificial intelligence (AI) is one of the most important features of any single player game. Getting it right is key to the experience: it has to be almost invisible, so players (sort of) forget that they are playing against a machine. It has to be clever and fast enough to be a worthy opponent, but not too much – humans are fallible, after all; and ultimately the player, as the hero of the story, is supposed to win. It has to make use of the game mechanics at hand, not just to be fun and varied but to show the player what can be done. This rings especially true in a game such as Mount & Blade II: Bannerlord, where skill-based combat and epic large-scale battles are at the core of the experience.
 
In our previous games, the AI performed adequately in combat, but it was by no means advanced. Battle tactics were quite basic in that AI armies would either launch themselves into full-out assaults or sit back and wait for the player to attack. No consideration was given to the terrain, and at no point would the AI try to exploit weaknesses in their opponent’s army or capitalise on any mistakes made by the player. This lack of depth made the AI more an obstacle, a nuisance, than a truly worthy opponent. With Bannerlord, this is something that has received a complete overhaul. We want players to be challenged, to be clever and make use of all the combat mechanics available to them if they want to emerge victorious -- and at times, to be punished for any unwise decisions or mistakes that they make. To do this, and taking into account that combat in Mount & Blade can be both one-to-one and in large battles, we had to devise a more advanced and reactive combat AI, broken into three separate categories:  individual, formation, and tactical AI.



Individual
Each individual agent in a battle is controlled by its own AI. Moving to a position (pathfinding), selecting a target, attacking and defending are all managed on this level. Individual AI needs to be extremely fast and responsive and its results should be correct within a very small margin of error (swinging a weapon, engaging an enemy that just charged them out of nowhere on horseback, etc.). In addition to this, orders need to be carried out across the entire formation at the same time. Ultimately, timing and execution need to be as close to perfect as possible.

To put it simply, individual AI needs to be as precise as possible to ensure that each agent can perform effectively in combat. It needs to carry out any orders that are issued to it, as well as, assess the current situation to make its own decisions on what actions to take.

And when you have hundreds of agents performing all of these calculations at the same time, performance becomes a huge potential issue that needs addressing (which in our case is solved by using parallel processing).

Formation
Formation AI sits at a level just above individual AI. Formation AI is used to issue commands to each agent within a formation and decide what behaviour that the formation should perform (i.e. attack, defend, flank, retreat, etc.). However, it is important to note that the orders issued by the formation AI only determine what is expected of each individual agent, but it doesn’t directly make them do anything: this is left to the individual AI to interpret and carry out.

The formation AI has access to the same interface and set of commands as the player. In other words, our combat AI doesn’t cheat! It uses every piece of information that a player would have access to (although, perhaps slightly more detailed and accurate than a player’s guesstimates) to make its decisions.

Tactic
Tactic AI is what gives an AI army its overall battle plan. It looks at the terrain of the battlefield, as well as the compositions of each army to determine the best tactic. To keep each battle varied and to further the emergent narrative for the player, this layer of the combat AI is influenced by the AI lord commanding the army. Some lords might be more cautious and prefer to seize the high ground before setting up in a defensive formation, whereas other lords might be a little more rash, putting pressure onto their opponents by committing to an early assault.

The tactic chosen sets the overall battle plan in that each formation knows what is expected of them but they aren't strictly tied to it. What this means is that each formation's AI will make immediate battlefield decisions independent of the tactic when necessary, such as exploiting advantages or pulling back when necessary, but when there isn’t an urgent action that needs to be carried out they will try to stick to the plan.

One way to look at it would be to think of the AI as having its own chain of command, with tactic AI being the general at the head of the army, issuing commands to its subordinates and expecting them to carry the order out to the best of their ability.



One of our main considerations while developing this new combat AI system was to ensure that any decisions that the AI makes are believable to players. The AI needs to make logical decisions that make sense to the player, otherwise, the system could be easily gamed and player immersion would be adversely affected. So far, we are pretty happy with the results. We think that Bannerlord’s AI will be a fresh challenge to returning players to the series, and provide players new and old players alike with dynamic combat experiences that test their individual combat skills and tactical prowess.

Finally, we would like to mention that Bannerlord’s AI is also moddable, too -- and its separation into three different levels is important for modders, making their life easier and allowing for more complex modifications. Tactical, formation behaviour and agent levels being separate is essential: just as commanders changing their orders during battle does not change their soldiers themselves, adding a new tactic doesn't require you to model every single formation behaviour or agent AI. Adding new formation behaviours doesn't require you to delve into agent AI either because the interface the AI uses and you will use is the medium between the hierarchies. This lets modders create a custom AI that suits their needs without breaking anything, using a complex or simple set of orders and logic to create new formation behaviours and new tactics using various formation behaviours.


In next week’s blog, we will talk to 3D Artist, Ülker Dikmen. If you have any questions you would like to ask her, please leave a reply in the comments and we will pick one out for her to answer!

Join the conversation and comment on the forums! (147 comments)