Military Unit Building Discussion (example: continue knight when rifleman available?)

Cybah

Emperor
Joined
Jun 22, 2007
Messages
1,481
You will notice, that the AI will always build mounted units - even if there are way better gunpowder units.

Example:

Knight available (10)

Rifleman available (14) or Grenadier (12)


AI will continue building knights for attacks.


Cavalry available (15)

Infantry available (20)


AI will continue building cavalry for attacks.



What do you think about this? Human players are highly priorizing building riflemen (if [potential] enemy has no/only a few grenadier units) and infantry units (always, since no units can stop them until tanks are available).
 
You will notice, that the AI will always build mounted units - even if there are way better gunpowder units.

Example:

Knight available (10)

Rifleman available (14) or Grenadier (12)


AI will continue building knights for attacks.


Cavalry available (15)

Infantry available (20)


AI will continue building cavalry for attacks.



What do you think about this? Human players are highly priorizing building riflemen (if [potential] enemy has no/only a few grenadier units) and infantry units (always, since no units can stop them until tanks are available).

I've noticed this and my theory is that the AI prefers to build mounted units because any city can build a combat II mounted unit under any civic... perhaps the wise thing to do would be for it to either switch civics so they can build better-promoted land units or prioritize the appropriate mounted unit tech once their land units get significantly ahead...
 
cavalry: combat1+combat2 < infantry without promotions

cavalry: combat1+pinch = 15*1.35 = 20.25 < infantry with combat 1 = 22


infantry is better in both scenarios... but:

cavalry is better at attacking cannons than infantry at attacking cannons. :lol:
 
cavalry: combat1+combat2 < infantry without promotions

cavalry: combat1+pinch = 15*1.35 = 20.25 < infantry with combat 1 = 22


infantry is better in both scenarios... but:

cavalry is better at attacking cannons than infantry at attacking cannons. :lol:

This response misses the point...

I said do one of the following... either:

1. Switch civics to build level 2 gunpowder units
2. Build mounted, knowing the AI gets very cheap upgrades... then research the appropriate tech

It all depends on priorities... regardless it would be a bad idea to make the AI routinely spam Combat I units... now it is stuck paying for poor units indefinitely

Keep in mind that flanking II is very useful against a protective opponent... even when I have assembly line, I build gobs of flankingII cavs if I think I'm going to war against a protective enemy. This combined with their ability to wipe out a lot of cannon makes them quite powerful.
 
A given civilization needs to plan out what kind of defensive and offensive military force it wants.

It then needs to look at what it has, and determine what needs to be done to become the force it wants.

Then, it needs to base it's build decisions off of approaching that military force.

We cannot, for example, say "knights are worse than riflemen, never build knights when you have riflemen", because you might actually need some knights in your military mix. But you might also have more than enough knights already, in which case it isn't worth building more...

I think that is a decent computer-understandable set of steps.

Have a disposable class (ie, doesn't get saved) that goes out and collects the number of units of each type and purpose.

Have a disposable class that goes out and collects knowledge about what kind of units are buildable and worth building.

Have a disposable class that goes out and collects knowledge about what units your rivals have access to.

Set a value for each unit based off of "are we short counters to enemy unit X (as a percentage of our force)", "are we short (units in role X)", "how good is unit X".

Divide by the cost of the unit (in raw hammers), and boost by the promotions the unit gets when built, to determine which unit we build at a given location.

The hard part might be the "we are short unit X, so increase it's value" factor.
 
I think the problem here is more do to do with the very very long gap between cav and gunships, most units have a logical upgrade path, to better versions, but this kind of breaks down a bit with cav as the gap is to large and really is crying out for a unit to be inserted into the space between
 
well this has nothing to do with AI unit building decisions.
 
I think the problem here is more do to do with the very very long gap between cav and gunships, most units have a logical upgrade path, to better versions, but this kind of breaks down a bit with cav as the gap is to large and really is crying out for a unit to be inserted into the space between

There's also a big gap between trebucket and cannon and between ironclad and destroyer. Of course there are mods the put units in the gaps for those. There's a bombard unit around somewhere and the wolf-something mod with all those ships. There's no obvious unit that comes after cavalry before gunship. The tank fills mostly the same role that a mounted unit would but since it doesn't obsolete or get upgraded from cavalry the AI doesn't see it that way. So can the AI be made to think of something as obsolete without it being officially obsolete by the game engine?
Of course one reason to still build knights with riflemen is because of flanking against trebuckets and catapults which because of the big gap before cannons might still be in use. It's a niche market for knights by that time, so can the AI understand when to use something of that limited use?
 
When choosing which unit type to build with UNITAI_ATTACK, the AI uses the following valuation of different units (from CvPlayerAI::AI_unitValue):

Code:
	case UNITAI_ATTACK:
		iFastMoverMultiplier = AI_isDoStrategy(AI_STRATEGY_FASTMOVERS) ? 2 : 1;
		
		iValue += iCombatValue;
		iValue += ((iCombatValue * [B]GC.getUnitInfo(eUnit).getMoves()[/B] * iFastMoverMultiplier) / 2);
		iValue += ((iCombatValue * GC.getUnitInfo(eUnit).getWithdrawalProbability()) / 100);
		if (GC.getUnitInfo(eUnit).getCombatLimit() < 100)
		{
			iValue -= (iCombatValue * (125 - GC.getUnitInfo(eUnit).getCombatLimit())) / 100;
		}
		
		break;

Now, iCombatValue is a little bit complicated ... :

1. (Combat strength)*100
2. * some fraction greater than 1.0 if unit has first strikes/chances
3. Divided by the best land unit combat strength anyone has built

So, it's basically a ratio of combat strengths. Note that all of these factors are based just on XML, they ignore any combat bonuses the units will get when built.

For the knights/riflemen case, we have:

Best land unit combat strength: 14
iCombatValue for rifleman: 100
iCombatValue for knight: (10*100)/14 = 71

So, the iValue calculations for the two are then (note: AI will not use fast mover strategy in this case, since combat value of slow rifles is higher than fast knights):

iValue for rifleman: 100 + 100/2 + 0 = 150
iValue for knight: 71 + (71*2)/2 + 0 = 142

These values are fairly similar, so IIRC the AI will still build UNITAI_ATTACK knights but will build more UNITAI_ATTACK rifleman, attempting to maintain an attack force of ~55% rifles, 45% knights or so.

For grenadiers vs knights, since 12 and 10 are much closer, then it will probably have more knights than grenadiers because of the value of their speed.
 
Would it be at all possible to add in a check based on UnitCombat Modifiers? According to that code, the AI will never build X-bows (unless it specifically wants UnitAI_Counter), and it wol't apropriatly realize the value of some UUs, like Landshnecks.
 
That could is just for UNITAI_ATTACK, the other UNITAIs more appropriate for X-bows (counter, specifically) definitely do check combat modifiers. UNITAI_ATTACK are supposed to be general purpose attack units for the AI, units intended to counter other specific unit types will join these attack stacks. If the stack then attacks a single unit in the field, then the counter unit will be used if the stack has one.

That's the logic the AI was built with.
 
OK. To be honest I was kind of being self serving in that request. I plan on changing Pikemen to being like Landshneks (+100% to mounted and melee), and was concerned the AI wouldn't build them as much as they should given that formula. UnitAI_Counter seems to be pretty rare...
 
GC.getUnitInfo(eUnit).getMoves() * iFastMoverMultiplier

so... the AI would not build knights when they have only 1 move?

maybe we should lower the value of additional movement points... withdraw is good but not important either... imo. what do you think?
 
Yeah, I'm not sure ... additional movement points are valuable and a good fraction of the UNITAI_ATTACK units built in the game will spend their time in small groups (2-4). When two knights are put together, then the AI gets benefit out of having the fast units and can travel faster.

But, when the fast UNITAI_ATTACK units group with slow units (happens frequently if fast unit isn't strongest land unit player can build), then basically the main benefit it that the AI can soon upgrade them to Cavalry/Helicopters.

Hmmm
 
When you look through the tech tree, you'll see that unit strength jumps from age to age will result in an approximately 50% strength increase per age. We all know what huge benefits there are to being an age ahead when facing an enemy. Those 50% stronger units make mincemeat out of the enemy units.

According to the formulas posted by jdog5000 above, the knight gets a relative 1.3333 bonus compared to the rifleman (one is multiplied by 2, the other by 1.5: 2/1.5 = 1 1/3 = 1.3333 rounded) which is close to the bonus that you get for being an age ahead. Next to that, the mounted units often are relatively strong when measured by base unit strength compared to other units from their age. The relatively large bonus for speed combined with the high base unit strength explains why knights compare to riflemen and cavalry to infantry. The cavalry vs infantry comparison would even make them equal if I understand the formulas correctly.

Since an attack stack derives its power from its size and fast units will be slowed by slow ones, the main advantage of fast units is a quick reaction force to invasion or a unit that can move out of the stack and can come back into the stack that same turn. There are no inherent combat advantages due to speed (flanking bonuses and retreat bonuses are independent).

I would definitely be in favour of reducing the bonus of speed to something like 10% per extra movement point (helicopters should have an advantage due to their 4 movement points compared to 2 for armor), although maybe there should be a rule of diminishing return for the last few extra movement points (1 + 0.1 + 1/2 * 0.1 + 1/3 * 0.1 + 1/4 * 0.1 + etc.). I however don't know exactly how the iValue of units influences the ratios at which these units will be build. So I can't see the full consequences of such a change.

In the end, I think knights should be build rarely when riflemen are available and cuirassiers should be build less than riflemen when both are available. Cavalry should be build rarely when infantry is available.
 
I would also prefer if the AI built tons of AT_infantery when the human player is building tons of tanks.

The AI is always building not enough counter units so far.

And, additional, the AI would need less counter units if the AI built more siege units (UNITAI_COLLATERAL).
 
Another issue with choosing units to build is that the AI doesn't seem to really identify the different needs for sea combat, land combat and air combat. Sometimes an AI will have a big fleet while it is being beaten on land. Sometimes they have large land forces while they're beaten in the air.

Would it be possible to store 3 different power values for land, air and water so that the AI could identify and counter the forces of its enemy better? Or would this require a massive rewriting effort of the AI?
 
Roland, unless the AI has a lot of sight visibility about it's opponents (thru units used as scouts and/or esp points visibility); that would be called cheating. The human does not have access to a broken down force count by air/sea/land, just a combined total solders on the stats screen.

What the human does is remember what units he saw and prioritize.

And there are times when it comes to air and sea that if you don't have the techs, it's just a waste of hammers to try to compete with massive inferior units.
(Such as if you can only build Airships and your opponent has several fighters. Or you can only build Frigates and your opponent has several Destroyers (or better).)
 
Back
Top Bottom