UnofficialCrusaderPatch / UnofficialCrusaderPatch2

Unofficial balancing patch installer for Stronghold Crusader 1
MIT License
430 stars 59 forks source link

Attack Criteria for the AI #157

Closed Heroesflorian closed 4 years ago

Heroesflorian commented 5 years ago

Some months ago, I did some experiments to try and find out the criteria by which different AI characters pick their attack targets. For some characters, results were pretty clear, but for a few others it was rather ambiguous, and back then I wasn't able to clear up all uncertainties or contradictory test results. (Also, just saying: I have even seen the Wolf switch attack targets mid-game without his current attack target getting killed, and without any other obvious/understandable reasons, despite the fact that the Wolf usually always attacks his nearest opponent... so possibly, all characters have some non-obvious secondary criteria or similar, that get triggered sometimes?)

Anyway, I put my findings into a google sheet, so this might be helpful for some people: https://docs.google.com/spreadsheets/d/1-i-wYaXOBXYD8Izgn5TJD4lJRf9rdqr0b3HPVr6QbUA/edit#gid=0

Now, one thing that always bugged me was that - while other options such as nearest opponent, weakest enemy Lord or opponent with the least troops usually make sense, to some extent - the "most gold" attack priority never seemed to work out properly:


So after all the previous info, I would like to suggest 2 things:

That way, the attack criteria would no longer doom certain AI characters in a 2 vs 1 or 3 vs 1 due to never actually going for a kill, and put everyone on a fair playing field, but still keep the character specific differences in place as good as possible.

And yes, I do think these changes to be relevant and somewhat important... I have had matches spanning 100-200 game years (without patch) where one Saladin (own improved AIV) fought 2 Richards (vanilla AIVs), 3 Pigs (vanilla AIVs), or even just 2 Rats (own improved AIVs) until he won the game, despite Saladin's victory being clear after 10-15 game years already, as he was impenetrable for his opponents, had tons upon tons of gold growing very quickly, and his opponents were out of gold, with ruined castles and very little remaining economy. Yet, Saladin just never made any effective attacks during the entire game, as he constantly moved back and forth between all opponents, depending on who happened to have 5 more gold coins at that moment, switching up his targets during running sieges literally a dozen times. When the enemy Lord is killed more or less randomly, with the opponent AI long starved and "knocked out", by archer patrols shooting at the lonely Lord for 10 game years nonstop, as Saladin didn't see a reason to finish off anyone, that is really painstaking. For some of the other "most gold" characters, similar matches have been observed.

Monsterfisch commented 5 years ago

I would interject that a better place for the most gold condition to me would be for harassing raids as they would be sent out to weaken the future opponent so he doesn't grow out of control combining that with attacking the poorest opponent would mean that the ais that use that kind of strategy would be working on a longterm goal while cutting their losses during attacks "short" as they would focus the weakest enemy. To me, that sounds like something very fitting for Salading the "alwaystalkingabouttacticsguy" very nicely.

PitchNeeded commented 5 years ago

I would interject that a better place for the most gold condition to me would be for harassing raids as they would be sent out to weaken the future opponent so he doesn't grow out of control combining that with attacking the poorest opponent would mean that the ais that use that kind of strategy would be working on a longterm goal while cutting their losses during attacks "short" as they would focus the weakest enemy. To me, that sounds like something very fitting for Salading the "alwaystalkingabouttacticsguy" very nicely.

Good idea!

Although sometimes an AI raiding the same opponent as they are sieging can be effective: I like the fact that Emir sometimes attacks with his siege force and raiders simultaneously at the same opponent, which is a lot of Arabian swordsmen! The enemy missile units are often distracted with the siege force meaning Emir's raiders have an easy time destroying the economic buildings.

Nizar can also kill the lord of a weak AI with one of his assassin raids, so he would be better still targeting the weakest AI with his raids.

AI raids in general have a bug though, they sometimes wait in the field in one place (or on aggressive mode) for reinforcements to arrive, rather than moving on to a new target, meaning they can get killed easily.

I know I said this before elsewhere on here, but it would be great if Emir, Phillip and Marshall's raiders (as they have the strongest raids for the AI), if an AI was weak enough and sending their 'panicking' message, rather than waiting for a gap to appear in the castle walls to send in their raiders, could target the weak AIs gatehouses to try and enter the castle and destroy the granary, marketplace, and in the case of Emir, even try and kill the AI lord.

Sh0wdown commented 5 years ago

Add an option to "lock" the currently chosen attack target while an attack is running.

this will be included in the next release

Heroesflorian commented 5 years ago

I would interject that a better place for the most gold condition to me would be for harassing raids as they would be sent out to weaken the future opponent so he doesn't grow out of control combining that with attacking the poorest opponent would mean that the ais that use that kind of strategy would be working on a longterm goal while cutting their losses during attacks "short" as they would focus the weakest enemy. To me, that sounds like something very fitting for Salading the "alwaystalkingabouttacticsguy" very nicely.

This only works to some degree, though. A single AI can not really completely shut down more than 1 or possibly 2 other AI players effectively, due to factors such as peasant spawning, economy, troop logistics etc. (And trust me, a single well-manned Wolf fortress is enough to make Saladin lose raiding and patrol troops faster than he can recruit new ones even with "endless" gold reserves, 100 popularity and constant recruiting...)

Plus, Saladin in particular is a very sucky raider - he only sends relatively small groups of horse archers for that, who neither are tanky, nor attack buildings, nor are many enough to be really dangerous, nor even hit the economy at all if there are soldiers nearby who will be targetted with higher priority than workers. Combine that with resources/farms near the opponent castle, and you have a very ineffective suicide force that doesn't really affect the opponent economy at all. (*) Pre-patch, this (combined with the weak Arabian swordsmen) was the reason why Saladin lacked A LOT of punch and takes forever to finish off some of the stronger AIs (or never achieve that at all even with huge economic superiority and military dominance). And even with the patch, Saladin still is not a good raider at all, of course, although at least his siege forces now are more dangerous. If Saladin would send slaves, assassins or swordsmen to actually attack opponent economy buildings, then his raiding could be relevant enough to possibly consider a dedicated strategy different from his main attack strategy/target. (* Depending on circumstances, they can still take out some of the opponents (defensive) patrol archers on the ground, but for that job, Saladin's own (defensive) patrol archers are enough and often more effective, so the (offensive) raiding horse archers provide no added value there, imho.)

Although sometimes an AI raiding the same opponent as they are sieging can be effective: I like the fact that Emir sometimes attacks with his siege force and raiders simultaneously at the same opponent, which is a lot of Arabian swordsmen! The enemy missile units are often distracted with the siege force meaning Emir's raiders have an easy time destroying the economic buildings.

Indeed! And for the Marshall, Frederick and Philipp, when the opponent castle is "opened" by the siege forces, knights can assist and rush in, helping overwhelm defenders and/or destroy granary and other important buildings.

AI raids in general have a bug though, they sometimes wait in the field in one place (or on aggressive mode) for reinforcements to arrive, rather than moving on to a new target, meaning they can get killed easily.

Indeeed! This often happens when the AI assigns additional (newly recruited) troops to a group of raiding troops: The AI sends the newcomers to the same location where the existing troops are, and only when they arrived, the whole group gets assigned a new attack target. Especially for the Marshal, this behaviour can be observed very frequently and is very annoying.

I know I said this before elsewhere on here, but it would be great if Emir, Phillip and Marshall's raiders (as they have the strongest raids for the AI), if an AI was weak enough and sending their 'panicking' message, rather than waiting for a gap to appear in the castle walls to send in their raiders, could target the weak AIs gatehouses to try and enter the castle and destroy the granary, marketplace, and in the case of Emir, even try and kill the AI lord.

Yeah, that could be cool. Or at least making sure that the AI sends raider troops at all when performing a siege attack, to take advantage of the opportunity to harass the opponent's economy while the defending troops are distracted.

this will be included in the next release

Great!

PitchNeeded commented 5 years ago

Can we also maybe have it that AI raiders attack closer enemy economic buildings first.

I was watching a match where Caliph had some farms at the front and sides of his castle and quarries at the back. Emir sent some Arabian swordsmen to raid but instead of heading for the closer farms first to destroy (which would have been sensible) they went all the way around Caliph's castle to try and attack a quarry, meaning they died due to a mix of archer fire, fire ballista fire and pitch.

Heroesflorian commented 5 years ago

Can we also maybe have it that AI raiders attack closer enemy economic buildings first.

That would be quite an effective improvement indeed! Also the slave groups of Caliph or Snake would be less useless in the mid game and beyond, then. Same goes fro Sheriff's macemen gang or the knights of some other AIs... and even Saladin's raider horse archers would be able to get some workers down at least, then.

PitchNeeded commented 5 years ago

Can we also maybe have it that AI raiders attack closer enemy economic buildings first.

That would be quite an effective improvement indeed! Also the slave groups of Caliph or Snake would be less useless in the mid game and beyond, then. Same goes fro Sheriff's macemen gang or the knights of some other AIs... and even Saladin's raider horse archers would be able to get some workers down at least, then.

Only Marshall, Nizar, Emir, Phillip and Frederick I would say are effective raiders in the late game.

Yeah I noticed that Caliph and Snake's slaves also sometimes try and go around entire castles to burn a target rather than attacking targets at the front and sides, making them not very effective.

Plus, Saladin in particular is a very sucky raider - he only sends relatively small groups of horse archers for that, who neither are tanky, nor attack buildings, nor are many enough to be really dangerous, nor even hit the economy at all if there are soldiers nearby who will be targetted with higher priority than workers. Combine that with resources/farms near the opponent castle, and you have a very ineffective suicide force that doesn't really affect the opponent economy at all. (*) Pre-patch, this (combined with the weak Arabian swordsmen) was the reason why Saladin lacked A LOT of punch and takes forever to finish off some of the stronger AIs (or never achieve that at all even with huge economic superiority and military dominance). And even with the patch, Saladin still is not a good raider at all, of course, although at least his siege forces now are more dangerous. If Saladin would send slaves, assassins or swordsmen to actually attack opponent economy buildings, then his raiding could be relevant enough to possibly consider a dedicated strategy different from his main attack strategy/target.

Yep I don't know what would be best to improve Saladin in terms of raiding, although slaves would go best with his horse archers as they are fast, they are maybe a bit 'evil' for his personality I think, plus could burn his own horse archers by mistake.

I know Saladin uses assassins to capture gatehouses, but I think assassins destroying buildings would be a bit too sneaky for Saladin's personality I think, although they are quite effective even in quite small groups as we see from Nizar's assassin raids.

Arabian swordsmen raiders would be great for Saladin and his personality, and certainly look very regal marching across the map to fit with Saladin being a powerful sultan :D , but only big groups like Emir sends are really effective and if Saladin is still creating horse archers as well to raid, this could get too expensive for him. Emir only concentrates on Arabian swordsmen for raiding, and he takes a while to gather a big enough group of Arabian swordsmen to raid (unless he has a lot of gold and can create them quickly), so he can afford it. Maybe Saladin could raid with big groups of Arabian swordsmen like Emir but only rarely, and use his horse archers the rest of the time.

YouMoMCallME commented 5 years ago

It would be better if Saladin killed the shooters on the walls than he waited for the wall to break .I mean horse archers. Because when Saladin goes on the attack, he leaves the horse archers idle, until he breaks the wall.

PitchNeeded commented 5 years ago

It would be better if Saladin killed the shooters on the walls than he waited for the wall to break .I mean horse archers. Because when Saladin goes on the attack, he leaves the horse archers idle, until he breaks the wall.

Maybe it happens sometimes, but I have never seen this happen much with Saladin, because Saladin actually moves his horse archers around the walls of the castle (and even sometimes uses his horse archers to destroy the wall) when he sieges so his horse archers don't get left behind often.

PitchNeeded commented 5 years ago

Add an option to "lock" the currently chosen attack target while an attack is running. This prevents brainless target switching mid-attack that usually ends in complete failures as siege engines are built in different places, move past well-defended castles during the attack in order to reach another opponent, getting destroyed in the process, armies marching back and forth between several opponent fortresses, etc. This would benefit characters targetting "most gold", but also those targetting "least troops" and "least power" to some extent, and would generally remove a lot of facepalm-moments from AI battles. The AI could still choose a new (potentially different) attack target for its next attack, of course.

Sometimes it works though, if an AI is planning to attack a certain enemy and its ally is at the same time attacking another enemy and has managed to breach that enemy's walls, it makes sense for the AI to switch targets to the castle where the walls have already been breached and to help its ally.

Especially with the AIs that use fast units in their sieges (Arabian AIs that use horse archers, or Pig and Sheriff who use macemen) and therefore can arrive quickly at the breach.

Heroesflorian commented 5 years ago

Only Marshall, Nizar, Emir, Phillip and Frederick I would say are effective raiders in the late game.

If the Sheriff manages to get his economy going properly, he can actually make a lot of money as well, and in that case his macemen raiding groups can get big enough (and fast, and frequent) to actually be quite effective as well, making him another quite good raider I'd say. I've already seen Sheriff destroy Wazir with macemen running all around and ravaging his farms (on balanced maps).

Add an option to "lock" the currently chosen attack target while an attack is running. (...) The AI could still choose a new (potentially different) attack target for its next attack, of course.

Sometimes it works though, if an AI is planning to attack a certain enemy and its ally is at the same time attacking another enemy and has managed to breach that enemy's walls, it makes sense for the AI to switch targets to the castle where the walls have already been breached and to help its ally.

Especially with the AIs that use fast units in their sieges (Arabian AIs that use horse archers, or Pig and Sheriff who use macemen) and therefore can arrive quickly at the breach.

Well that depends a bit... if the Sheriff's whole macemen army stops attacking one enemy and instead runs across the entire map, possibly right through pitch ditches of other opponents, it is a bit meh... But generally the AI could become a bit smarter in terms of teaming up - e.g. attack together (same time, same opponent), use breached walls (which currently does not automatically cause target switching, only if the current attack criteria happen to switch as well) to change targets "smartly", etc.

Heroesflorian commented 4 years ago

With lock-target-during-attack and AICs available, this isn't really relevant anymore. (For potential new, "fancy" attack criteria, a separate issue would be in order anyway...)