Im making a couple of threads about the ai for people like DrJambo and myself to have discussions about what can be done to improve the ai. This one will be about the battle ai. I'll post more later.
Im making a couple of threads about the ai for people like DrJambo and myself to have discussions about what can be done to improve the ai. This one will be about the battle ai. I'll post more later.
Creator of:
Lands to Conquer Gold for Medieval II: Kingdoms
Terrae Expugnandae Gold Open Beta for RTW 1.5
Proud ex-Moderator and ex-Administrator of TWC from Jan 06 to June 07
Awarded the Rank of Opifex for outstanding contributions to the TW mod community.
Awarded the Rank of Divus for oustanding work during my times as Administrator.
Never noticed this thread!![]()
Anyway, for reference I've copied and pasted across the content of the post I made on the battle analyser:
I have something regarding the new 1.2 battle-analyser section of the config_ai_battle file that you might want to investigate for your mod.
Have you ever noticed that if you bring superior missiles to a fight against the AI, the AI will quite often sit out the duel using its inferior missiles, essentially allowing you to decimate the AI army? Well, in the battle-analyser section there's the following code:
This code was introduced in 1.2 and probably has a big impact on the passive AI. Now, as I see it and from the tests I've done there's seems to be an oddity here. I don't see how a friendly to enemy melee ratio and an enemy to friendly ranged ratio can both be greater than 0 and make any sense to the AI, when the end product is the same, i.e. for us (I think) to be perceived as being overwhelmingly powerful.Code:<battle-analyser> <!-- ratio of friendly to enemy strength to be considered more powerful --> <friendly-to-enemy-strength-ratio>0.8</friendly-to-enemy-strength-ratio> <!-- ratio of friendly to enemy melee strength to be considered overwhelmingly powerful --> <enemy-melee-strength-multiplier>3.0</enemy-melee-strength-multiplier> <!-- ratio of enemy to friendly ranged strength to be considered overwhelmingly powerful --> <friendly-ranged-strength-multiplier>3.0</friendly-ranged-strength-multiplier> <!-- ratio of friendly strength to enemy ranged strength to force attack --> <friendly-ranged-strength-divisor>5.0</friendly-ranged-strength-divisor> <!-- distance behind the defensive line the enemy must reach to be considered to have broken through --> <enemy-position-buffer-distance>25</enemy-position-buffer-distance> </battle-analyser>
Anyway, in the tests I did where my missile heavy (4 missile units, 2 infantry units, 1 general) Byz army faced a Sicilian army of 2 Norman knights and 1 pavise crossbow (army ratio was 6:5 in my favour), the AI just sat and traded missiles until it was dead or routed. No attempt was made to engage the infantry and almost all Normans were dead. If the AI isn't going to retreat immediately this is clearly a daft tactic. So, I changed thetoCode:<friendly-ranged-strength-multiplier>3.0</friendly-ranged-strength-multiplier>and this had a great impact. The AI appeared to trade a couple of rounds of missiles and then engaged its infantry. It still lost of course, but it played sensibly given the situation and took more casualties from me as a result.Code:<friendly-ranged-strength-multiplier>0.3</friendly-ranged-strength-multiplier>
Try it and see what you think. It's possible the last value could also be out of sorts but I haven't tested this one fully since changing the aforementioned one produced good results.
The other critical part I had suggested investigating in some thread over at the ORG was infantry skirmish units that have a small range, i.e. javelin, hand gunners and naffatun units. There's something not quite right about the way they're set up in the default battle_ai file and when the AI uses them, they more often than not get stuck in a seesawing motion between skirmishing and trying to get within range for shooting. I also found that a well placed unit of cav, i.e. just in front of your front line missile troops, can effectively render these units in the hands of the AI completely useless!
The questionable value seemed to be this entry:
The fact this value is higher than 1 seems to be the root cause. As far as I can tell this means that if the unit is moving and attackers come within 1.1 x their range, they'll skirmish. If this is the case, then no wonder they never seem to get settled to fire. Now, I have made other changes like increasing their standard range, and increasing their "stop at this distance..." value, but the main change which seemed to help prevent this AI seesawing motion was setting this value to lower than 1 like so:Code:<!-- don't skirmish until attackers are within this fraction of the missile range --> <range-factor> <moving>1.1</moving>
The complete file is attached if you're interested. Like I said above, I also increased the default range of all javelin, hand gunners and naffatun. This is now 70.Code:<!-- don't skirmish until attackers are within this fraction of the missile range --> <range-factor> <moving>0.8</moving>
Those changes all look good to me. Have you had a look at any of the siege ai stuff?
Creator of:
Lands to Conquer Gold for Medieval II: Kingdoms
Terrae Expugnandae Gold Open Beta for RTW 1.5
Proud ex-Moderator and ex-Administrator of TWC from Jan 06 to June 07
Awarded the Rank of Opifex for outstanding contributions to the TW mod community.
Awarded the Rank of Divus for oustanding work during my times as Administrator.
A little yes.
I made it so the AI is less likely to retreat from defending around the breaches. Turning and running isn't always a very good plan and the AI always seemed a little over eager to abandon this stage. Plus in moving from breach defence to defending the streets the AI would face their units the wrong way, i.e. towards the plaza! This is especially bad for pikemen as you can imagine.![]()
I also play with a slight modification of Klink's cool garrison script and so I increased the strength ratio at which the AI would sally. Sallying AI usually equals dead AI and getting the AI to sally is a relatively easy way to capture settlements.
In term of attacking siege AI I made some modifications to the formations file. Mainly trying to ensure the AI general unit is kept as far back from the main force as possible. This is most important for the "Wall Assault" formation which the AI is quite fond of using, so I added a special Generals block and placed it -50 behind the main bulk of units.
If you have a file compare utility you can have a look at these changes I've made and any others I might have made to the formations and config_ai_battle files, which I've attached.
Any questions, just ask.
I'm tickled now, what did you change about my garrison script?
This line is interesting:
This is a problem because the AI puts several units on walls with one-rank thickness right behind each other, which makes the missile units unable to shoot. Increasing this to 20 helped, but caused new problems when apparently the AI couldn't deploy on the smaller wall levels.Code:<!-- controls the spread of the units along the wall as a percentage of unit width --> <unit-spread>1.0</unit-spread>
Also, this line:
That has to be 2.0 at least, buffer or no buffer.Code:<!-- reform to this amount times the tower range --> <tower-range-scale>1.5</tower-range-scale>
I added a special Generals block and placed it -50 behind the main bulk of units.
Ha, I put at -120. Won't do to have it within range of anything.
Request, could you make a general's block for all the bridge crossing formations? I just easily killed three many-starred Mongol generals at a bridge because the terrain somehow put the general unit in front of all the others.
Another problem is when the AI is pushed sufficiently out of the breach defense formation it tries to reform, in spite of the hundreds of enemy soldiers hacking at it all the while. Maybe there's a formation tolerance there to mess with?
It was just the suggestion I had made on your own thread - swapping Crossbow Militia for Partisan Militia on lev = 4 and lev =5 for France. Think I also increased by one the number of Nubian Archers for one of the top levs for Egypt.
Was does unit-spread of 1.0 actually mean? Does it actually mean the number of rows or is it more complicated?
Yeah, I had tinkered with this in pre-1.2 versions of Med II, but since I have yet to encounter an issue with this in 1.2 I haven't modified it yet.
Indeed, it's likely a higher value like this will be even better. I take it you've never encountered any AI formation problems on any siege maps yet using a large value like this? In otherwords I take it the AI's always been able to set up its formation ok?
Yes, this shouldn't be too difficult. However, I do remember that the AI sometimes retained its cavalry across the other side of the river (certainly pre-1.2 it did this). Has this changed in 1.2? Does the AI now rush its cavalry across too?
Could you explain this more thoroughly? What do you mean when you say the AI is pushed sufficiently out of the breach? Forced back through melee? If so, you probably want to look at the following code entry in config_ai _battle under defend-perimeter:
As you can see I've already increased mine by 25 % to encourage the AI to stick out the breach fighting a bit longer before progressing to the next stage, defend-streets.Code:<!-- enemy got 25% of their force into the settlement --> <enemy-penetration>0.5</enemy-penetration>
If it's the street fighting you want to prolong then look at these values:
Remember through that by default the street fighting stage isn't applicable to castles, fortresses and citadels.Code:<!-- if the enemy outnumbers us by this proportion (in the perimeter) then fall back --> <force-ratio>1.6</force-ratio> <!-- have our forces depleted too much in this stage? --> <loss-ratio>0.7</loss-ratio>
Whoa...another goldmine of information!
*DrBeast will keep a close look at this thread!
This means, that the unit assigned to defend the wall, will cover 100% = 1.0 of the wall, so it spreads out.<!-- controls the spread of the units along the wall as a percentage of unit width -->
<unit-spread>1.0</unit-spread>
If you set the value to 0.5, then it will only cover 50% of the wall, resulting in a deeper defense line.
Great info about battle AI DrJambo +rep for that.
I already use your changes, it works very good, would like to know more from you about different parameters, esp about skirmishing![]()
“Great empires are not maintained by timidity.” ― Tacitus