AI vs AI Map Battles (Autocalc)

Users who are viewing this thread

Hi all,

Tried searching, but didn't see if this was asked / talked about by the devs or the community yet, but I was wondering how AI vs AI Map Battles (i.e Autocalc) will be handled in Bannerlord?

In M&B / WB, it is dealt with in a very simple way (imo, too simple), using number of troops & troop levels.

kt0, a modder during the M&B era tried to improve it by expanding the variables required to make a plausible simulation (e.g by factoring in troop equipment, terrain, etc). However, I think I've only seen two mods use it: PoP and Sword of Damocles (M&B edition). I also don't think it was 100% finished. Not sure if MadVader finished/improved it for PoP, but they do have one of the best Autocalcs around.

In TLD, autocalc is quite important, given that a huge party size is one side's advantage (i.e Evil - esp. Orc factions). However, because of WB/M&B's simple autocalc, we'd have to do some workaround to make this possible. Not the best, but we have something acceptable.

So, I just would like to know how Bannerlord will be handling this :smile: Perhaps some people also have an idea on how AI vs AI Map Battles / Simulations SHOULD be handled.

Thanks and apologies if this has been asked / answered before.
 
AI vs AI map battles ?
Yes, please  :grin:

Not the hardest thing to implement to the game and I really want to see how Khuzait horse archers handle Vlandian knights.
Is their AI smart enough to dismount them first with parthian shots or are they unable to keep the distance between themselves and the Vlandian knights?
 
Talking for warband;

Troop-to-troop calculations should yield the best result if you are crazy enough, otherwise class-to-class that will include the factors of terrain, party morale, hero buff, troop level and equipment which are mentioned already. Maybe tactics skill of the leader as well.

Guess the same for bannerlord as well
 
This is tricky. More complicated calculations are certainly possible, by including troop equipment and skills in the equation. All these details are only technicalities though. How would you, for example, determine how the terrain affects the battle and which side is favored by the map generator? Also, when it comes to factions that rely on, let's say, more exotic tactical choices (such as the Khuzait horse archers), how will their advantages be taken in account? Lastly, something that I've always been curious of is how would one effectively calculate the impact of ranged troops early battle before they eventually clash with the attacking cavalry or infantry? Furthermore, there are frequent situations when ranged troops suffer no casualties in battle, and a good calculator should also take in account that possibility and assess whether an army can actually protect its ranged troops well enough.

All in all, I'd hate to be the guy working on this feature, but I'm nevertheless interested how Bannerlord handles auto-resolve.
 
The Bowman said:
how Bannerlord handles auto-resolve.

I would expect them to run multiple simulations on the real thingy (now they have the capability to do so) to help identify which variables affect the results on a AI x AI battle. Then use those results as parameters for the auto-calculation.

that could include stuff like morale, terrain, type of troops, type of enemy, and so on.

assuming that the AI will be capable of good decisions when fighting on a real time battle (not like Warband suicidal rush)
 
I believe that Taleworlds has said that you can see a lords personality in the way they command their troops. I wonder how that will be taken into consideration when AI fight each other.
 
I don't remember if it was regular old Diplomacy or its perfect son Dickplomacy or both who did it, but they also expanded on autocalc battles by adding terrain variables, so it's possible and shouldn't be too hard, which makes me assume it's very safe to assume Bonerlord devs are already gonna do it. But then I don't remember much, so be sure to look into it before taking my word as proof.
 
PoP uses the same old engine autocalc - the one where only 2 numbers (total party strength of fighting sides) are given to the engine.
It seems like in PoP troop strength values are pre-computed by python rather than computed inside the game, but it's the only difference.
It's always just 2 numbers in the end, and if troops' levels accurately reflect their strength (which is something one would expect from a good mod), why not simply use levels? After all, unless we're talking about custom troops, regular soldiers' equipment is unchanged during the game.

And with all due respect to old PoP devs, I would hardly call PoP autocalc strength calculation formula one of its best features. For example, one of their KO sergeant (mounted) used to have higher strength than the knight of the same order (also mounted). And their Lion Knights were as good as 16 farmers (taking into account how much the game engine favors quantity over quality in autocalc battles, this gap is too small). And one of the most common piece of advice on beating noldors (best archers in the game) was to autodefeat them with berserkers or gladiators (both are high-level troops wearing very little or no armor and using 2h swords).
PoP didn't take into account KO upgrades (except CKO, but in this case the formula was rather ... unorthodox, and CKO's equipment wasn't taken into account).
I don't know about the state of things now though (all this digging was done in 3.6).

PoP's formula for calculating autocalc strength is more complex than that in other mods, but it doesn't matter in the end.

And terrain adjustment is used in plenty of mods, including every mod that has Diplomacy.

To solve issues such as "beating noldors with gladiators", one has to completely replace the engine autocalc with manual autocalc, but taking into account how many battles are happening on the map in large mods at each moment, and how "heavy" would be the code if one is to take into account party composition, I don't think it's a good idea performance-wise (maybe in Bannerlord if it learns to use CPU better, but definitely not in Warband).

The current autocalc is pretty OK. And the most important things about soldiers' autocalc strength, in my opinion, are:
1) Avoiding abuses like "beating noldors with gladiators" by simply not giving ridiculously high levels to fragile glass cannons.
2) Avoiding abuses like "beating knights with farmers" (and avoiding issues like "I was to lazy to fight 20 bandits with my 100 heavy knights, so I decided to autocalc them, but they somehow managed to kill 2 of my knights") by keeping the gap high as autocalc already favors quantity over quality (in Perisno a lvl60 elite heavy knight is as good - on the paper - as 140 farmers autocalc-wise).
The autocalc_strength/upkeep ratio should rise the stronger the warrior, not the other way around, like in PoP.
One the most common myths "Warband doesn't take into account troop strength, only numbers" and the following advice "just fill your garrisons with farmers" stem from such bad curve and the illusion it creates.
 
the problem with the auto-calc system is that it ignores the context of the battle. If they can add that to both the AI decision and the auto-calc we would get a more balanced world around us.

take for example a army that depends heavily on infantry and archers against cavalry. If the defending army can manage to fight on a location that supports their fighting style (like a hill or forest), they shouldn't be destroyed in the same way it would happen on a open field. Or things like weather and time of the day (heavy rain, etc).

there is also the big difference on the siege location. Certain locations are easier to defend than others. Or are best for a specific strategy/combination of forces. So you can have simple parameters for that (in this castle archers have a value of 5 until 50 units, heavy infantry value of 2 until 40 units, cavalry value of 2, etc).

and lets not forget the idea of ambushes (devs talked about it) and the effects of situations like that on the result of a battle.
 
I'd love to see autocalc include tactical skill, morale, terrain advantage, defensive bonus and a bonus for fighting on home soil in addition to levels and numbers. As all battles are risks this should be adjusted by a random plus or minus x%. Every army can have a good or bad day.

mlJgJ.jpg
 
Thanks for all the great ideas. I do hope Bannerlord has a different way of handling autocalc, and I do wish they talk about it in one of the blogs.

@Leonion, thanks for the breakdown. I play PoP a lot but never use Autocalc myself, and of course, I can't really see what is happening ai party vs ai party without testing it out myself (which i rather not do, cause I rather play it), or without dev tools. So your observations are great.

@kalarhan, I completely agree. In our mod, 50 high level elven archers won't have a difficult time against 200 low/mid-tier orc party in a field battle, but in autocalc, you can expect heavy losses. Context here would be that these are elite archers, but because of autocalc, troop strength (calculated by our own new TLD formula) may not reflect the actual in-game strength of these troops.

@NPC99, great sample formulas. We had do to something similar in TLD, but we don't take your variables into account. We only deal with levels.

Technically, because autocalc is simply a mathematical formula, we can simulate different 'battles' in excel, then adjust our variables according to what we want to happen. Am I right in this?

I hope there are better ways to test these in Bannerlord too :smile:
 
Khamukkamu said:
Technically, because autocalc is simply a mathematical formula, we can simulate different 'battles' in excel, then adjust our variables according to what we want to happen.
:???:
How?
I'm afraid I don't understand.
 
Leonion said:

you can use equations on Excel, and even code via VBA. Then put that on a graph, because everything looks better on a graph  :mrgreen:

it can also be done in different ways like a quick Python script, and so on. Enter your data, let the simulation run, see the result (and compare with the expected casualities for a balanced game). You could even run this using Warband engine if the only language you (random reader) know is MBScript.
 
No, I mean... what equations?
Is there a formula of engine autocalc, i.e. the content of the black box called inflict_casualties_to_party_group, somewhere?

Because without it I don't see how we could build a mathematical model just in Excel.

This conversation actually inspired me to meddle with game_event_simulate_battle code a little bit today, but the effect of all the changes I can only see in the game.
And, besides, they're random and depend a lot on what soldiers engine decides to kill during each round and probably some other random variation, because the exact same battle between 2 closely matched parties can have different/opposite outcomes during different trials (save/load).
 
Leonion said:
Is there a formula of engine autocalc, i.e. the content of the black box called inflict_casualties_to_party_group, somewhere?

its a normal distribution, you can get the numbers with a simple simulation (run the process a few hundreds times using Warband engine, a logger, and a quick statistics analysis) to test it.

ps.: you can also simple stop using the operation and write your own script, and replace calls for the operation with calls to your own custom code.
 
kalarhan said:
ps.: you can also simple stop using the operation and write your own script, and replace calls for the operation with calls to your own custom code.
Yeah, I was talking about this part in my first message here.  :smile:
But I don't think it's a good idea to add complicated code to perhaps the most frequently used script in the game.
So I just adjusted soldiers' strength and rewrote the formula for total strength, and to hell with it. :grin:

Normal distribution...statistics analysis...I need my university notes...
I worked in SPSS and in Excel with correlations and regression and factor analysis several years ago, but applying any of this to autocalc in Warband... ehhh...
 
Leonion said:
I worked in SPSS and in Excel with correlations and regression and factor analysis several years ago, but applying any of this to autocalc in Warband... ehhh...

Well math and statistics are a big part of game design, to the point they have dedicated people just for that  :wink:

VC introduced some changes to the strenght script that takes into account the terrain x type of unit, in case you want to give it a look. It also changed the siege mechanics. Nothing major, but a positive change from Native system.

In the modding blog they mentioned that the game mechanics would be easy to configure with parameters, so we shouldnt be surprise if this (auto-calc) already has a bunch of variables we can adjust to the specific mod conditions.

Leonion said:
But I don't think it's a good idea to add complicated code to perhaps the most frequently used script in the game.
this script is not called often enough that you would worry about performance (lagging in the world map). Just consistency of results (something easy to follow with a logger). But the easiest way to manipulate the results are to change the strength calculation, and let the casualities as a black box.

-> changing strength also has the positive effect of changing AI behaviour on world map (run or fight system). It makes little sense to adapt the battle itself, but not the AI decision if should even fight or try to escape instead.
 
kalarhan said:
VC introduced some changes to the strenght script that takes into account the terrain x type of unit, in case you want to give it a look.
Terrain type (its role in autocalc) was introduced at least in Diplomacy, maybe even in some earlier projects, so it's not actually a VC innovation.
Unit type complements it (different types of units benefit differently from different terrain), Diplomacy and VC identify the type of units using troop_is_guarantee_[] flags, PoP and Perisno have somewhat more complex algorithms that store/"cache" unit types in slots in the beginning of the game.

kalarhan said:
-> changing strength also has the positive effect of changing AI behaviour on world map (run or fight system).
Speaking of which - do you know what defines strength in this basic "fight or flight" behavior on the global map? Is party_calculate_strength secretly an engine-called script or does the engine use its own "black box" script for this?

kalarhan said:
It makes little sense to adapt the battle itself, but not the AI decision if should even fight or try to escape instead.
Uh-uh, not necessarily.  :smile:
Engine fails to predict outcomes of a battle if unusual parties are used.
For example, in Perisno there are special lords that use 1 troop only - their special soldiers. One of these lords is OP as his troop consists of lvl 66 soldiers. There is another lord who only uses lvl 50 knights.
So these badass lords who wreck anything in real-time battles run around the map with their 50-70 soldiers and have no fear, but as soon as they stumble into some big fat lord with 200 soldiers of all sorts, they get rekt. And it doesn't help that their (badass lords') autocalc strength is 6000 while the other lord's autocalc strength is 2000. Native battle algorithms favor quantity over quality too much.
So that's why I have to adjust game_event_simulate_battle too.

P.S. I got curious about the actual frequency at which game_event_simulate_battle is called so I decided to check.
In Perisno in 428 hours it was called 8140 times which is approximately 19 times an hour...which I guess can be described as moderately frequent...
 
Leonion said:
so it's not actually a VC innovation

never claimed it was. Trying to talk about who did what first is silly after 12 years and thousands of mods out there, many of which we don't even know about as they are in other languages/closed source. It was just a reference to a actual implementation that I know of and can show the code for.

Code:
do you know what defines strength in this basic "fight or flight"
it is a combination. It also use AI parameters like courage of a party, aggressiveness, etc, in combination with strength (a dynamic parameter calculated by a script, but that also keeps the result on a cache slot). Those parameters are a good way to make bandits run away from big parties (even if they have similar STR), as they are not suppose to be heroic in behaviour (instead they should be hunting easy prey).

Code:
party_set_aggressiveness              = 1606  # (party_set_aggressiveness, <party_id>, <number>),
                                              # Sets aggressiveness value for the party (range 0..15).
party_set_courage                     = 1607  # (party_set_courage, <party_id>, <number>),
                                              # Sets courage value for the party (range 4..15).
party_get_ai_initiative               = 1638  # (party_get_ai_initiative, <destination>, <party_id>),
                                              # Gets party current AI initiative value (range 0..100).
party_set_ai_initiative               = 1639  # (party_set_ai_initiative, <party_id>, <value>),
                                              # Sets AI initiative value for the party (range 0..100).

Code:
Engine fails to predict outcomes of a battle if unusual parties are used.
That is part of it. The engine is not failing per si, it was just not made for that, as the code was created for a particular game (Native) and its rules. That is why I said changing just one part of the system (the casualities) without the world behaviour (should I even try to fight those guys) leads to unbalance.
Two parties with 200 STR, one is on big disadvantage (for whatever ruleset the mod has), that still decides to hunt down the enemy (and comity suicide) would be a problem. That comes from changing the battle simulation, instead of the STR calculation.
 
Back
Top Bottom