More Unit AI troubles uncovered in XML

peter450

Prince
Joined
Sep 24, 2006
Messages
392
I been going through the unit infos XML of late and found an interesting curio

Chariots

The unit AI for chariots goes like this

<UnitAIType>UNITAI_ATTACK</UnitAIType>
<UnitAIType>UNITAI_COUNTER</UnitAIType>
<UnitAIType>UNITAI_PILLAGE</UnitAIType>

For the Immortal (persian chariot) they are the same except for this a not unit AI

<UnitAIType>UNITAI_CITY_COUNTER</UnitAIType>

Question is, should this be
A not there
or
B there on the other two chariot units?
 
This one is not a problem.

There are two ways the AI will decide to assign a UNITAI to a particular unit, either if it's specifically allowed in XML or if the unit satisfies some properties in CvPlayerAI::AI_unitValue (and it's not specifically barred in XML).

In this case, because the Immortal has an extra combat bonus against archers while the others only have offensive bonuses against other units, then the logic in CvPlayerAI::AI_unitValue would consider CITY_COUNTER a valid choice for the immortal. It's not a good choice though since archers are rarely offensive, so Firaxis is appropriately blocking CITY_COUNTER.

So, you could do option B and block the other two, but it would have no effect since they won't take it anyway.

CvPlayerAI::AI_unitValue is a fairly interesting function, for those of you messing around with XML settings for units I recommend taking a look at what's considered valid for different unitai types.
 
Thanks for that, clears that one up nicely

Theres one more thing though, after i noticed that i compared some of the other UU to the vanilla counterparts

Spanish conquistador, has a counter-unit AI

The cossack does not despite also being a counter unit to mounted, is this right?

numidian cav has the same unit AI's as the conquistador, but lacks the not city counter AI, to stop it being used in this way, should it not have it like the conquistador? based on your earlier explantion of the immortal AI it seems like it should?

Janissary has no counter AI entry despite it's 25% bonus's that make it quite a good counter unit to quite a lot of things
 
Cossack: Yes, it could have the COUNTER AI type.*

Numidian: No, it's fine not to block CITY_COUNTER in this case because the unit gets its combat bonus against melee units which the enemy will use to attack cities. The difference with the Immortal is that the Immortal has a boost against archers, which are unlikely to be the base of a (successful) city attack stack, so other units would be better in the CITY_COUNTER role.

Janissary: Yes, this could also have COUNTER.*

* In CvPlayerAI::AI_unitValue, the AI will consider both of these units to be valid recipients of a COUNTER AI, so the AI will build them that way without the explicit setting. I think this is Firaxis' solution to not having to always specify in XML exactly how each unit must be used.
 
Also, Immortals get defensive bonuses, so sitting in place would often be a better choice compared to other mounted units. Another reason to keep them off the counter list.
 
I'm thinking that the AI should get whatever encouragement it can get to use Immortals (and the Incan Q) against enemy cities since the AI primarily defends cities with Archers.
 
Back
Top Bottom