Easy way to change AI attack priority?

rhettrongun

Prince
Joined
Mar 19, 2011
Messages
341
Location
TX
I'm looking for an easy way (ie. simple xml change) to lower the AI's preference for targeting cities for attack over enemy units.

My main problem is when I see it attacking a city with its aircraft that is well behind enemy lines. Sometimes I even see it continue to attack a city after its health bar is already at a minimum. This ends up effectively wasting the aircraft a lot of times, as they have a city that is ripe for the taking, but no chance in actually getting past the units guarding it. All the while the aircraft it has been using are taking steady damage.

The other part I don't like is that it tends to lead to a lot of city flip flopping, as 2 AIs fighting each other will just keep trying to take the same city from 1 another rather than wipe out the enemy units.
I realize this strategy has its merits sometimes, but in most cases I see it as just stupid and wasteful.

Here is where I'm suspecting a change might help:

GlobalAIDefines sheet>

<!-- Operation AI Defines-->
<Row Name="AI_OPERATIONAL_CITY_ATTACK_DEPLOY_RANGE">
<Value>5</Value>
</Row>

Basically I'm guessing that lowering this value to about a 2 might make the AI wait to begin targeting a city until it gets a unit within 2 hexes of it. This is the only entry that stood out to me as a possibility, but there are probably some sections I haven't looked through yet.

After looking further it might be in this sheet instead:

Civ5TacticalMoves>

<Row>
<Type>TACTICAL_CAPTURE_CITY</Type>
<OperationsCanRecruit>false</OperationsCanRecruit>
<OffenseFlavorWeight>100</OffenseFlavorWeight>
<Priority>150</Priority>
</Row>
<Row>
<Type>TACTICAL_DAMAGE_CITY</Type>
<OperationsCanRecruit>true</OperationsCanRecruit>
<OffenseFlavorWeight>100</OffenseFlavorWeight>
<Priority>15</Priority>
</Row>

A lot of other interesting entries in this section that might be worth adjusting. One thing I'm wondering is what <OperationsCanRecruit> does.

Anyone know if this works? If it doesn't is there another way to change this?
 
None of the things you listed would change bombing priority, except perhaps the TacticalDamageCity Priority number. Chances are there is another entry for units that has a lower priority number.
 
None of the things you listed would change bombing priority, except perhaps the TacticalDamageCity Priority number. Chances are there is another entry for units that has a lower priority number.

Yep, there are entries for damaging/destroying high, med, and low quality enemy units. The damage entries are the ones I would guess might matter in how the AI decides whether to attack the city or the units with aircraft. Med & Low are both set at 15 and 12 respectively. The other entry that could affect the target priorities for aircraft is this one:

<Row>
<Type>TACTICAL_SAFE_BOMBARDS</Type>
<OperationsCanRecruit>false</OperationsCanRecruit>
<OffenseFlavorWeight>100</OffenseFlavorWeight>
<Priority>60</Priority>
</Row>

It has a very high priority compared other entries. Maybe the AI sees attacking cities behind enemy lines as "safe bombard" attack options. If this is the case, it would explain its desire to do so.

Anyways, when I have the time I guess I will just have to play around with these and test what effect they have. Was hoping someone had already done this, as it is sure to be time consuming. :( I'll post what I find regardless.
 
I've gotten some pretty good results. Good enough that I will keep them until I see something screwy happening anyways.

The AI seems to be targeting units a lot more now, although it still goes after cities too. The big change from what I can see is that it is bombing cities when it has a chance to capture the city in the same turn. This is much better than bombarding a city behind enemy lines that it has little to no hope of capturing in the same turn. Here is what I ended up changing:

Code:
<GameData>
	<TacticalMoves>
		<Update>
			<Set Priority="20"/>
			<Where Type="TACTICAL_AIR_SWEEP"/>
		</Update>
		<Update>
			<Set Priority="30"/>
			<Where Type="TACTICAL_AIR_INTERCEPT"/>
		</Update>
		<Update>
			<Set Priority="102"/>
			<Where Type="TACTICAL_POSTURE_SURGICAL_CITY_STRIKE"/>
		</Update>
		<Update>
			<Set DefenseFlavorWeight="50" OffenseFlavorWeight="50"/>
			<Where Type="TACTICAL_ATTRIT_HIGH_UNIT"/>
		</Update>
		<Update>
			<Set DefenseFlavorWeight="50" OffenseFlavorWeight="50"/>
			<Where Type="TACTICAL_ATTRIT_MEDIUM_UNIT"/>
		</Update>
		<Update>
			<Set DefenseFlavorWeight="50" OffenseFlavorWeight="50"/>
			<Where Type="TACTICAL_ATTRIT_LOW_UNIT"/>
		</Update>
		<Update>
			<Set DefenseFlavorWeight="50" OffenseFlavorWeight="50"/>
			<Where Type="TACTICAL_DESTROY_HIGH_UNIT"/>
		</Update>
		<Update>
			<Set DefenseFlavorWeight="50" OffenseFlavorWeight="50"/>
			<Where Type="TACTICAL_DESTROY_MEDIUM_UNIT"/>
		</Update>
		<Update>
			<Set DefenseFlavorWeight="50" OffenseFlavorWeight="50"/>
			<Where Type="TACTICAL_DESTROY_LOW_UNIT"/>
		</Update>
	</TacticalMoves>
</GameData>

So the intercept and air sweeps are obviously just a couple changes that I wanted, and had nothing to do with the original purpose of this mod component. I made the surgical city strike change first, and didn't notice any difference in what the AI was doing. I decided to keep it and then make the 6 updates that follow it. Those were what seemed to lead to the difference I saw. I think it basically added those tactical options to the AI's offensive strategy repertoire.

I'm a little worried that lowering the DefenseFlavorWeight from 100 to 50 will mess up the AI's defensive capabilities, but I didn't see anything indicating it was causing trouble in the time I spent testing this.

I welcome any help on this of course. I'm not certain this really changed anything, as I'm only going off my subjective observations. Another person taking a look at this would be very useful.
 
I won't have time to test soon, but I'll keep an eye on this thread, interesting, if only all these values where documented...
 
Looks like what I thought I was seeing as an effect earlier was either a fluke, experimenter bias, wishful thinking, or whatever you may call it. A couple more tests and I was clearly getting the same old city bombardments where a lot of surrounding units were being ignored.

I do have a more consistent way to test for changes now though.
 
Surgical city strike must be for something unrelated, as it had no effect even when set at a priority of 1. Maybe for the AI using nukes or guided missiles.

These are the updates that definitely reduced the AI's obsessiveness with bombarding cities:
Code:
<GameData>
	<TacticalMoves>
		<Update>
			<Set Priority="34"/>
			<Where Type="TACTICAL_AIR_SWEEP"/>
		</Update>
		<Update>
			<Set Priority="35"/>
			<Where Type="TACTICAL_AIR_INTERCEPT"/>
		</Update>
		<Update>
			<Set DefenseFlavorWeight="50" OffenseFlavorWeight="50" Priority="38"/>
			<Where Type="TACTICAL_ATTRIT_HIGH_UNIT"/>
		</Update>
		<Update>
			<Set DefenseFlavorWeight="50" OffenseFlavorWeight="50" Priority="34"/>
			<Where Type="TACTICAL_ATTRIT_MEDIUM_UNIT"/>
		</Update>
		<Update>
			<Set DefenseFlavorWeight="50" OffenseFlavorWeight="50" Priority="30"/>
			<Where Type="TACTICAL_ATTRIT_LOW_UNIT"/>
		</Update>
		<Update>
			<Set DefenseFlavorWeight="50" OffenseFlavorWeight="50" Priority="145"/>
			<Where Type="TACTICAL_DESTROY_HIGH_UNIT"/>
		</Update>
		<Update>
			<Set DefenseFlavorWeight="50" OffenseFlavorWeight="50" Priority="130"/>
			<Where Type="TACTICAL_DESTROY_MEDIUM_UNIT"/>
		</Update>
		<Update>
			<Set DefenseFlavorWeight="50" OffenseFlavorWeight="50" Priority="120"/>
			<Where Type="TACTICAL_DESTROY_LOW_UNIT"/>
		</Update>
		<Update>
			<Set Priority="125"/>
			<Where Type="TACTICAL_CAPTURE_CITY"/>
		</Update>
	</TacticalMoves>
</GameData>

I'm not certain that the TACTICAL_ATTRIT_ priority updates are necessary, but this setup seems to work so I'm using it for now. The key was lowering capture city to a priority level lower than some of the destroy unit entries. I think the updates for the flavor weights on the unit entries are probably necessary too.

The end result is the AI now tries to clear enemy units before going all in at a city. I don't think this is the case for all units with this setup since the cap city entry is actually higher than the destroy low unit entry. I don't really know exactly which units are considered low, med, and high yet. From what I saw the AI seems to like going after naval vessels that are close by though.
 
Back
Top Bottom