AI tweaks - Battle AI

Elvince

Chieftain
Joined
Nov 22, 2005
Messages
39
Hello everyone,
I tried to do some XML tweaks to the AI to encourage it to buid more troops for war and to take your cities in higner priorities when attacking. let me know what you find out, the mod is in the mod browser.

waiting for your feedback!

V4 is out:
- AI more aggressive when at war
- AI will not sign peace too quickly especially during stalemate.
- AI wil be more enclined to kill your damaged unit
- AI will focus more on capture your cities
- AI will create more units to defend already owned cities

list of changes V3 (compared to AI):
- when attacking cities ai will target more the city than before
- when attacking cities ai will try to destroy your units before attacking unharmed units
- when AI thinks it has enough military units it will create more units than before (still lower priority than building)(new from V2)
- when at war AI will favor a lot more offense and defense than before (economy should be more war focused)
- when preparing for war AI will favor offensive units, then defensive and a lot less archery units
- it will create a bit more military building when preparing for war
- city states more defensive with their army
- when AI thinks it is winning wars it will favor a bit more defense (to avoid being defenseless if another civ attacks when all their army is elsewhere)
- when AI thinks it is loosing war it will favor a lot more defense than before
- when the AI needs ranged it should create also other types of units




Elvince
 
May I ask you what file and what line did you modify to change AI cities attacking priority modifer?
 
you will find a lot to fiddle with in that aspect in CIV5TacticalMoves.xml. enjoy :)
 
Thanks but do you understand this:

<Type>TACTICAL_PILLAGE</Type>
<OperationsCanRecruit>false</OperationsCanRecruit>
<OffenseFlavorWeight>100</OffenseFlavorWeight>
<Priority>40</Priority>

Can you give me small tutorial please? How should I change this to make AI pillage more often (right now he almost never does)
 
The biggest problem with battle AI is pathing and coverage. units constantly block each other and they keep throwing archers to the frontline and then get annihilated by player's cavalry.

I played a game on huge map immortal, the most unit types I saw from AI is ranged units, very little melee units, and almost zero mounted units. my cavalry, once upgraded with mobility, can run around mow down archers without fear of retaliation.

If only AI made a few mounted units, they could actually do some damage.
 
The biggest problem with battle AI is pathing and coverage. units constantly block each other and they keep throwing archers to the frontline and then get annihilated by player's cavalry.

I played a game on huge map immortal, the most unit types I saw from AI is ranged units, very little melee units, and almost zero mounted units. my cavalry, once upgraded with mobility, can run around mow down archers without fear of retaliation.

If only AI made a few mounted units, they could actually do some damage.

is that with the mod enabled? curious as to how well this mod works.
 
Could you give a short summary of what's changed?

Also, if the AI builds more units, doesn't it make it even more "backwards"? I think the main problem is not with the numbers but the lack of strategy. I even got used to rarely ever building land units, what minors give me is normally more than enough to grind up the AI army in some defensive spots.

And did you do something with siege units? I've yet to see any being used by the AI. Especially shocking after Civ4 AI's catapult obsession. :) My guess there is that the AI don't build those because of it's absolutely inability to screen anything, so it would be just wasted hammers. But did you try that?
 
I'm looking at your mod, and it's hard to figure out what you did because it consists largely of copies of the game's own XML files.

The big idea in Civ5 modding is that your mod only needs to include the values you're changing, not the ones you're leaving the same. That lets it coexist with other mods. The project sounds promising, but you should sort this out early in development!
 
re Inverted: I think that the AI building more units is a good idea, up to a point.

Building too many units would indeed make it lose in the economy race, but too many times I've encountered AIs that just roll over and let me stomp them because they have like 3 units. Or even militarily powerful AIs who leave their capital undefended when my city 6 tiles away has a sizable army. (Gee, I wasn't planning on a conquest victory, but I may just take up that offer!)

It seems like it should be possible to tweak the AI's assessment of "can my neighbors mercilessly crush me?" without giving it an unhealthy obsession with military units.
 
There is two parameters that I modified that I think improves the game. Base Units to defend per city is 1 default, I put it at 3. Second there is a base number of units which are set to 2 default I put it at 4. The AI now defends better and does not attack like a crazy person with all their units.

Works great. Its in Global AI defines,

<Row Name="AI_STRATEGY_DEFEND_MY_LANDS_UNITS_PER_CITY">
<Row Name="AI_STRATEGY_DEFEND_MY_LANDS_BASE_UNITS">
 
If I understand correctly, that means that the AI will keep 3n + 4 units, where n is the number of cities, in their territory, instead of n+2. Am I right? Tripling the units per city seems excessive.

Do large civs ever manage to launch an attack in that situation? If you have 10 cities, keeping 34 units around that you're not even using for war has to be hugely expensive. I think a subtler change would work better, such as from n+2 to n+6.

Or maybe I'm misunderstanding it. Is there a list of what all these XML rows actually mean somewhere?
 
I played a game on huge map immortal, the most unit types I saw from AI is ranged units, very little melee units, and almost zero mounted units. my cavalry, once upgraded with mobility, can run around mow down archers without fear of retaliation.

If only AI made a few mounted units, they could actually do some damage.

I actually did reduce the importance of building archers in the current version compared to melee units. I am not sure there is a specific factor for mounted units. I'll check.

I'm looking at your mod, and it's hard to figure out what you did because it consists largely of copies of the game's own XML files.

The big idea in Civ5 modding is that your mod only needs to include the values you're changing, not the ones you're leaving the same. That lets it coexist with other mods. The project sounds promising, but you should sort this out early in development!

rspeer, you are definitely right mate, I went the old fashion way... I will try to clean it in a few version, right now I am trying to see which factors have an impact.

There is two parameters that I modified that I think improves the game. Base Units to defend per city is 1 default, I put it at 3. Second there is a base number of units which are set to 2 default I put it at 4. The AI now defends better and does not attack like a crazy person with all their units.

Works great. Its in Global AI defines,

<Row Name="AI_STRATEGY_DEFEND_MY_LANDS_UNITS_PER_CITY">
<Row Name="AI_STRATEGY_DEFEND_MY_LANDS_BASE_UNITS">

Matte, thx mate I'll look into it for V3, but I don't want to cripple too much the ai capacity to attack.

everyone please let me know what you see as different when trying the mod regarding wars with the AI. I am working on V3 but lack usable feedback. I will modify my original post to be more clear about my changes.

Elvince
 
If I understand correctly, that means that the AI will keep 3n + 4 units, where n is the number of cities, in their territory, instead of n+2. Am I right? Tripling the units per city seems excessive.

Do large civs ever manage to launch an attack in that situation? If you have 10 cities, keeping 34 units around that you're not even using for war has to be hugely expensive. I think a subtler change would work better, such as from n+2 to n+6.

Or maybe I'm misunderstanding it. Is there a list of what all these XML rows actually mean somewhere?

We can only guess on what the base mean, I suspect it means 1 city 7 units 2 cities 10 units. In my current game that seem to be the case. Flavors of leader also affect this. That why some dont have any defenders in vanilla.

I increased them higher to see an effect and it worked. Right now I want my AI to defend better as they suck at attacking. :)

When they fix the tactical AI, I would lower these. I also lower maintenace ost to let the AI have more troops without being penalized, I really would like them to keep a decent defense and at the same time be able to attack.


As I mentioned before the changes I made greatly improves early game AI, as they are less likely to be mad(Want to declare war) at a civilization thats way off beacuse they have no units
 
Great to see this mod come up already! :goodjob:
So I have an idea for how to improve the AI's proficiency in battle, it's in keeping with your tweaks which account for how much the AI sucks at using ranged units:

On defense, the AI should park a siege(or at least its best ranged) unit inside its city. This way it will be able to continue to do reasonable damage until the city is taken. The AI sucks at protecting these units from attacks and its too easy to go for them first. The only solution is to have one at least in a city where it is temporarily invulnerable.
 
hey bobby I'll look into it, but I did not find any xml being that specific.
you should try my mod as for what I can notice so far the AI builds less archers but more of other types than before, making it more dangerous when attacking...
 
Thanks Elvince. I'm going to give your mod a go after my current game wraps up. I had another idea which you can try and implement in your mod as well. One of the main problems with the AI in combat is not only does it not use units well, but it also fields way too many outdated units.

Your mod is going to make them field more units which is better, but I feel it may be more efficient if in conjunction with that, the AI strongly prioritises upgrading its units (you'll need to make upgrading cheaper as well). If you also make it so warriors upgrade to spears then you'll have gone a long way towards balancing out the power of the horseman rush which is ridiculously OP at the moment.
 
Feedback:

I am currently using your mod on a small pangea map with 6 civs and a couple of city states.

Well it seems like the ai prepared better for war, but it failed landing on my coast since i blocked the few tiles that lead to me by land it tried using ships and i was surprised that i might end up fighting for survival cause of the massive transport invasion.

Turns out i was wrong.

They put their units into transportmode, and landed on their own coast again...with numerous units.

they got nailed by an arriving barbarian trireme after 5 turns of waiting at my coast... none of the 7-8+ units ever made it on my coast which was defenseless.

Never has the ai actually attacked my cities. They mostly walked around them trying to avoid to get hit by it aswell...
 
Have you been thinking of do some adjustment to battle bonuses?

I think the AI is severely handicaped by the possible bonuses and postioning advantage the player has at their disposal.

I currently change my game and lowered bonuses

1. Great General 15%
2. Positions 10%
3. Morale Honor 10%
4. Oligarchy 15% Bonus in homeland.
5. Fortify bonus 5% per turn - max 5 turns. 25%


I also have upped XP level to 15 from 10. Changed Range XP to 1 per attack or defence. This makes XP farming much harder and new units will have a chance against veterans , it also stops the powerful ranged units from climbing to fast. I also lower minimum damage for ranged units and upped hps to 15 from 10. Combined with the changes to bonuses this reduced the effect of uber archers drastically or the overpowered effect possible in some situations for other ranged units. Range units now mostly soften up the attacker and you still need melee units for the quick kill.

The tactical battles play much more evenly now, and the AI number advantage actually makes a real diffrence. You have to be more smart about using terrain.

You still get a bonus for positioning correctly but not as much. The Melee units have more room to manouver before they get cut down. Its harder to just use range units to snipe the melee units before the reach you specially in rough terrain.

I think Firaxis intentionally created higher bonuses so it made larger difference to improve the fun level of positiong and generals etc, but it bascially made it like everybody is playing on chieftain level when it comes to tactical battles. The huge problem with the way it currently works is related to the diffrence strength do to the math of battle, no wonder people can take the whole world with a few units. The AI production advantage is nullified because of the high strength diffrences due to these bonuses. This farily easy to realize, but as I said I think fun won over challange and balance.

And features that AI cant use that changes the balance to the degree these bonuses do, breaks the game balance, even if they are really fun on paper.
 
I think the main problem is not with the strong defense bonuses, as that is one of the rare things that AI actually realize in warfare. The main problem is that the AI is way too much obsessed with attacking. If you see an AI unit on hill+forest that you really dont want to attack, all you have to do is to move to a nearby defense hex and the AI will attack your unit. In which case its good position does no good to it.

Now that I had the chance to see siege and ships in the hands of the AI, Im not surprised the devs made those very low priority. Siege units (like ranged actually) are used by the AI as if they were melee. It will move its catapult right at your melee unit before trying to fire with it. The only chance it will use siege units at range is when the frontline is blocked by other units, but as soon as those fall, the siege units advance. I find it hard to believe but it still seems that they forgot to code the AI to at least try to use ranged units at range.
And for ships, there is a strong reason the AI doesnt like to build them: it is totally unable to use them. (much like sea transporting units that tend to just sit at your shore and never disembark) The brightest use was when it pillaged my work boats near a city, but once that was done, it just left the ship there to be shot at by the city, didnt even bother to shoot the city more than once every 3-4 turns. Likewise I could sail my caravel right through a pack of ships (frigates and destroyers) without the AI considering to attack it. Its a joke, really.

So I think for now you're best off if you make the AI strongly emphasize on melee units and try to make it a bit more defensive.
 
Back
Top Bottom