Results 1 to 13 of 13

Thread: Commanding AI reinforcements

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Commanding AI reinforcements

    Does anyone have experience with AI allied armies and the battle editor?

    I want to set skirmish units in skirmish mode, spear units in some kind of "stay put" mode (I mean they just have to stay where they are) and sword and axe units in melee mode ( they have to engage enemy units in melee). This in theory should be as straightforward as 1+1=2.

    However, I have rarely been able to control AI armies so that they do something as sensible as that. The spearmen seem to run around in random directions chasing ghosts, skirmish units attack the enemy in melee and the melee units sit and wait for the enemy heavy cavalry to charge them and do not seem to even lift a sword when this happens.

    Normally I fight the battle with my own commanded army and as long as my side is attacking and stays aggressive, what happens looks realistic. All these other AI armies have no chance to hurt themselves while my commanded army is routing the enemy. They are just there for the show. This time however I am trying to simulate a historical battle in which my side is the defender. It is crucial that the missile units skirmish, the spearmen hold the line and the melee units reinforce the parts of the line under strain. They can't just do random stuff.

  2. #2
    Teutonic Warlord's Avatar Semisalis
    Join Date
    Jul 2011
    Location
    Sitting behind my computer. Aren't you?
    Posts
    422

    Default Re: Commanding AI reinforcements

    Since you are doing this in custom battle, I suggest getting the retrofit mod first. It adds all of the goodies from Kingdoms like a little option for your AI reinforcements during the battle. For each army you can only select one stance: aggressive, defensive, or a mixed form. You still can't tell them exactly what to do in battle, but each army will act based on what stance you gave them. So, you might be able to create one army of spearmen, one army of melee units, and one army of archers. If that doesn't work, the only other options I can think of is looking around for a mod that lets you control more than 20 units in a battle or use two computers and use LAN so that the other computer's army will do just what you want them to. Hope this helps.

  3. #3
    /|\/|\/|\/|\/|\/|\/
    Join Date
    Jun 2005
    Posts
    10,770

    Default Re: Commanding AI reinforcements

    I suggest my mod because it has the best battle AI

  4. #4

    Default Re: Commanding AI reinforcements

    Quote Originally Posted by Taiji View Post
    I suggest my mod because it has the best battle AI
    I have tried a couple of mods, are you talking about DLV or DLV+BB? Not sure what the latter is. DLV is good, but I am not sure it would solve the problem of the allied spearmen going off for random walks on the battlefield. I will check.

    By the way, I am using the battle editor, not custom battle, to define the positions of the components of each army on the battlefield - for which there is historical information. Moreover the custom battle tends to set up each "army" as a separate army, with cavalry in the flanks, missile units infront, etc, which is annoying, though as Teutonic Warlord said, it gives some rudimentary control (attack, defend, missile - very difficult to use effectively).

    I also have the feeling that the enemy AI avoids doing battle with the human player and attacks the AI-controlled "allied" armies instead.

    In any case, I am working towards a solution but it is trial and error. For example, setting a line of spearmen as "reinforcement" in the battle editor, makes them stay completely still until engaged in melee and then only move a little, so that solves one problem. I think a balanced AI should work in such a way that whichever side you take, the friendly and enemy AI controlled armies in a slug fest, left on autopilot, should have similar losses. In many of the mods, the AI-controlled allied armies are simply massacred if you let them get a piece of the action. Considering that the enemy AI is not that great, it is a real pain to watch how the "allies" fight.

    One other problem is the enemy AI tactics. The historians talk of a continuous front that was impossible to break. The battle AI instead scatters the enemy army and concentrates into opportunistic cavalry raids on the weak point of my formation. Sure I can rearrange my army into an unbreakable compact square, but that is not how the historical battle took place. It is not a good simulation to try to keep an extended long front while the enemy just skirmishes around trying out pinpoint attacks on the weak spots and flanks. So I would need to make the enemy AI also fight in a certain way. It is not about good AI behaviour, it is about restricting the friendly and enemy AI to fight the battle in sensible but also in a historical way.
    Last edited by Geoffrey of Villehardouin; September 12, 2011 at 12:00 PM.

  5. #5

    Default Re: Commanding AI reinforcements

    The battle editor crashes in DLV 4.0, at least in my computer (Windows 7).

    Does it work ok in 6.3?

  6. #6
    Kine's Avatar Libertus
    Join Date
    Aug 2011
    Location
    Malaysia
    Posts
    78

    Default Re: Commanding AI reinforcements

    Kingdoms reinforcement AI is better. The OP sounds very much like Medieval2 vanilla.

    Anyhow, the AI does a unit versus unit check when deciding who and where to attack. It is predictable and can be manipulated to create a scenario that you want. You have to be familiar with the units and counter-units that the AI works with. Generally you'd want to pay attention to what units you are pitting against one another. Normally the AI will not engage units that it knows it has no chance of winning against (there are exceptional cases).

    In terms of overall strategy, the computer has none other than the artificial rules they have to work with. The computer emphasize on formations almost exclusively with little regard to the overall tactical situation. This can be a pain but you can work around it by omitting certain units that's messing with your realism. Simplest recommendation would be to start with only one core unit type and adding one more as you work out how the computer react to the changes.

    A fail scenario example would be in getting an AI controlled town militia army supported by cavalry to attack a line of dismounted knights. The AI in this case will favour cavalry raids and leave the line battle till absolute last if at all (top picture). In the test battle I fired up, the AI's center battle line never even engaged and it opted to use the melee units to bulk up the flanks instead, leaving itself open through the center which is remarkably unrealistic... But by tweaking the unit composition a little, you can coax the AI into fighting in a certain way. Trying to get the computer to fight a line battle for eg. you'd need a more balanced unit vs unit scenario (bottom pic). Here the AI is more receptive to getting dirty in a long line because of a fairer match up plus the absence of power units that might've given it other ideas.

    Spoiler Alert, click show to read: 


    As for skirmishing units, well there's no hope in that. Skirmish mode is broken and I cannot remember which Battle AI mod that made it to work semi-decent. Could be XBAI can't remember.

  7. #7

    Default Re: Commanding AI reinforcements

    Quote Originally Posted by Kine View Post
    Kingdoms reinforcement AI is better. The OP sounds very much like Medieval2 vanilla.

    Anyhow, the AI does a unit versus unit check when deciding who and where to attack. It is predictable and can be manipulated to create a scenario that you want. You have to be familiar with the units and counter-units that the AI works with. Generally you'd want to pay attention to what units you are pitting against one another. Normally the AI will not engage units that it knows it has no chance of winning against (there are exceptional cases).

    In terms of overall strategy, the computer has none other than the artificial rules they have to work with. The computer emphasize on formations almost exclusively with little regard to the overall tactical situation. This can be a pain but you can work around it by omitting certain units that's messing with your realism. Simplest recommendation would be to start with only one core unit type and adding one more as you work out how the computer react to the changes.

    A fail scenario example would be in getting an AI controlled town militia army supported by cavalry to attack a line of dismounted knights. The AI in this case will favour cavalry raids and leave the line battle till absolute last if at all (top picture). In the test battle I fired up, the AI's center battle line never even engaged and it opted to use the melee units to bulk up the flanks instead, leaving itself open through the center which is remarkably unrealistic... But by tweaking the unit composition a little, you can coax the AI into fighting in a certain way. Trying to get the computer to fight a line battle for eg. you'd need a more balanced unit vs unit scenario (bottom pic). Here the AI is more receptive to getting dirty in a long line because of a fairer match up plus the absence of power units that might've given it other ideas.

    Spoiler Alert, click show to read: 


    As for skirmishing units, well there's no hope in that. Skirmish mode is broken and I cannot remember which Battle AI mod that made it to work semi-decent. Could be XBAI can't remember.
    Many thanks for your helpful post. Yes I am using vanilla and variants, since the majority of Kingdoms based mods require patch 1.5 which I do not want to install as saved old campaigns would not be compatible. I've managed nevertheless to get a better skirmishing behaviour by deploying the attacking enemy close to my own starting battle line and I mentioned above a strange solution that works on how to make the "allied" spear line stay put. The main remaining problem is the enemy AI behaviour, i.e. the near chaotic scattering of the computer player's forces. If any mod fixes that, it would have to factor in the assigned relations between its own units. This happens when you group units, so in theory it is possible. The code is in there somewhere. If anyone knows a mod that does that or how the battle editor could do that, I would be grateful.

  8. #8
    Kine's Avatar Libertus
    Join Date
    Aug 2011
    Location
    Malaysia
    Posts
    78

    Default Re: Commanding AI reinforcements

    I failed to mention that modded AI will make it worse. On top of the unit checks the AI also analyzes it's surroundings for counter or stronger units, enemy forming up rank in the rear or flank etc. Dunno for sure how often they do these checks but from observation it is not continuous. Moded Battle AIs actually improves this thus making the computer controlled units behave even more 'unrealistically'. Most modded AIs were tuned to win battles against humans. What you want is to dumb the AI down. Or make them blind outright so they react to less things going on around them. You could try asking in the modding workshop on what settings to change. I know it's there because AI units cannot see the entire field (or atleast react to movements far away so there is a visibility setting you could adjust).

    But if you're not into editing files and stuff there are some things you can do to coax a straight up line battle:

    1. Make your lines wider and shorten the enemy AI's - and reduce any options of the AI flanking your lines. This will force it to commit to a simple head to head.

    2. Cavalry in seperate army - AI's uses formations almost exclusively which is a problem. If they have horses in their formations they will behave more in an 'Arcade' fashion. If you can place horses in your scenario as a seperate army it may be enough to not influence the other unit types.

    3. Stronger enemy units - they behave better if they 'think' they'll win a 1 on 1. Ofcourse the reality is human controlled armies can / will win against AI ones despite the disadvantage. But atleast the enemy AI behaves better as they die. Placing a peasant unit as your line's center is a near sure fire method of getting an engagement going. Alternating regular and weaker units along your line can get the enemy AI to spread evenly as it engages.

    4. Bait - this is subjective in terms that it'll only work in specific conditions. And what works in one battle might not when you replay the same battle if you or the AI does something different in the next game etc. But the idea works. Placing obvious pro-units can get the corresponding anti-unit to engage them. for eg if I wanted the enemy to consistently flank left I'd put an archer unit unprotected on that side to draw the enemy cavs there.

    5. Room to re-maneuver - formation is the biggest culprit here. I think vanilla med2 AI sticks to the standard double line with flanking cavalries. Taking cavalries out of the formation leaves them with a simple double line. One of the main causes of scattered battles is the broken skirmish mode and the insistence of AI's double line formation. On both offense and defense ranged units will be deployed ahead of the melee line. While defending, the AI hopes that the skirmish mode will cause the ranged units to retreat behind the main body but in practise they'd end up stuck in limbo just infront of the front line. In offense the frontline can never get their melees to echelon past the ranged units on time. In either cases you're going to have to solve the issue because these 'stuck' units are what's causing the AI problems. A solution would be to emply the English flanking archers line. This way they both stay out of each other's way.

    Last note on room for maneuver is if the AI battle line is supported by reserves behind them. It doesn't have to be a second line, just reserve units hanging back. I've noticed that if they have other options to counter human maneuvers they tend to leave the main body alone if it's already engaged and it'll use its' reserve units to effect. This is about the only thing it does right. The issue is in getting the AI to not touch their reserve units until the main boady has engaged. You could either deploy the enemy closer so the main line engages early or have the reserves deployed way back behind the frontlines so it will not prematurely commit to something stupid like bulking up the flanks.

  9. #9

    Default Re: Commanding AI reinforcements

    Thanks again Kine, you have made some good suggestions. I guess with these relatively snall armies and plenty of space to manouever, modded AIs have a point. Anyway, I am using more and more artificial ways to restrict the space (fences, woods, settlements, muddy fields and the like). Of course the enemy still breaks up its ranks but cannot scatter all over the place. I may have to post my question in the modders forum.

    Thanks again.

  10. #10
    Kine's Avatar Libertus
    Join Date
    Aug 2011
    Location
    Malaysia
    Posts
    78

    Default Re: Commanding AI reinforcements


  11. #11

    Default Re: Commanding AI reinforcements

    Thanks so much Kine +rep

  12. #12

    Default Re: Commanding AI reinforcements

    I don’t know if there is not much interest in setting a battle with the Battle Editor, or if those with some knowledge have not read my post. I've worked out a few things about the battle AI that should be of help, if anyone is interested.

    So, the historical battles available in the game have been scripted with thousands of lines of custom script, and you have to be paid for it to put so much effort in it. That means that most of us can at best only hope to make small modifications to the already available generic battle AI script found in config_ai_battle.

    The problem with the battle AI is that formations are set in the config_ai_battle script to the usual infantry double line with cavalry at the flanks and missiles in front. This code may be possible to replace with other code but it would require enormous amount of writing and testing again, so if you do that, you can hope for a job perhaps with CA.

    That means, if you prepare a battle in the Battle Editor and the deployment does not seem to conform with that code, or if you want to deploy lines of spearmen with reserves, etc, or masses of cavalry, the AI controlled armies (friendly or enemy) will start rearranging themselves, trying to deploy in the way the code tells them to. If they cannot do that easily, for example if one army is just the spearmen or if the attackers are all cavalry, then they just mill around randomly. This is probably why even the Mongols in the game are given infantry. That is not very good for an all cavalry army but it is absolutely suicidal for an all spearman army, as you can imagine, especially if they are the defenders, which they likely will be, as in Hastings. But even if you make balanced armies on one side and just cavalry on the other, the cavalry still wins hands down, despite of spending so much time milling around because of a second part of the script. That involves various bits of code labelled as outflanking. What this code does is to take the cavalry around the enemy formation to hit the infantry in the rear, leaving the centre open, quite unhistorical unless we are talking about the Mongols. The more balanced AI armies have not much of a defence to this strategy. They do not form squares, nor protect their flanks with impassable terrain nor protect their backs in some way, there is no such code, they really have no answer back - and they get massacred, despite looking slightly more cohesive.

    As an aside, I am not sure a general would use this type of formation, with cavalry in the flanks, archers in front, etc, if he only had units of a size less than a regiment involved in battle (as is the case in the game) and with so much empty space for cavalry to roam freely. Forming a square as a default (and for simplicity) would serve the defender much better.

    The best way to set a historical battle in the Battle Editor as a defender is this. You set the defending units that should not move (spearmen) as reinforcements to enter in minute 1. I.e. press F2, then when you set one of the armies, tick the box that says Reinforcement? And slide the top arrow to 1 (Joins in 1 minute real time). It is best to do that for all main armies so that they all appear on the map simultaneously, 1 minute after the game starts. The defender will be frozen, as if they were reinforcements to enter from a map edge, and will not move much, so the spearmen will in effect hold their battle line reasonably well. Archers will fire as if on “fire at will” and skirmishers will skirmish after a fashion (maybe even better than normally) and quite safely so, don’t let such considerations worry you. Just the spearmen will try to stay in place (may revolve a bit around their centre after being attacked or may move forward a few steps, but nothing quite as disastrous as marching off in random directions). The attacking army, those armies set as reinforcements, will be a bit sluggish in breaking off trying to redeploy itself, which you can exploit by pelting them with arrows which will force them to move to engage the defenders, rather than begin to mill about randomly trying to redeploy themselves in some new arcade-like line-up.

    Actually you cannot do this for all armies, you need one army as non-reinforcement, so make the reserves as your and the computer player’s controlled armies and set the main armies on either side of the battlefront as reinforcements. To do that you also need to have the Num of supporting armies in the Battle Editor set to 1, 2 or 3 depending on how many armies will appear on minute 1 (defenders stationary and attackers slow to redeploy).

    Three pieces of advice to make the attackers attack the defenders rather than ride a merry-go-round:

    1. Make the values for heavy horse or any other unit you want to use as the attacker’s main melee unit high against whatever melee unit they attacked historically in the config_ai_battle script. Do that in the section called <melee-manager>
    2. You can disable outflanking by setting the minimum number of units required for outflanking to 21. Some outflanking may still happen by chance, because of the other properties of the script.
    3. Quite important: Set the values in the <battle-analyser> relatively high, if the attacker still hesitates to attack and tries to redeploy.

    You may have to make some more minor tweaks to the config_battle_ai script to achieve your effect. Rename the original as config_ai_battle_original or something like that. Then when you have finished with the battle and you want to go back to the original script, rename your custom script appropriately.
    Last edited by Geoffrey of Villehardouin; September 25, 2011 at 01:18 PM.

  13. #13
    Kine's Avatar Libertus
    Join Date
    Aug 2011
    Location
    Malaysia
    Posts
    78

    Default Re: Commanding AI reinforcements

    a file you might be interested in is the descr_formations_ai.txt and as you rightly observed the sim uses a triple-line cavalry on the flanks formation. sadly CA only made one formation template for open field battles ie. a one size fits all formation. this file can be edited however to add more templates that the AI can choose from so you can make an all cavalry formation, spears and archers double line etc. but due to lack of documentation and tutorials covering the file, I haven't been able to edit it properly without the game crashing. you might have more luck though.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •