How is Military Strength Calculated?

Resipsa

King
Joined
Jul 20, 2012
Messages
998
When trying to decide whether or not to delete obsolete units it would be helpful to know whether those obsolete units contribute to your military strength. I might be inclined to play an Honor Game and keep my obsoletes in cities to gain +2 culture and +1 happiness and then go Autocracy and use gunboat diplomacy if those obsoletes actually contribute.

My thinking is that they don't, I played a game a few months ago where I simply massed LKs and still couldn't "bully" the CS even though basically the CS was surrounded by LKs.
 
I'm not sure how it is calculated exactly, but they changed bullying of city-states in the latest patch to make it easier, since it was nearly impossible to do on higher levels with any units.

All combat units, obsolete or not, and your cash determine your military power AFAIK
 
From this thread, author is r/civ mod Putmalk

http://www.reddit.com/r/civ/comments/1d0lz5/how_the_ai_computes_your_military_strength_based/

If you want to be feared by the AI, here are some things you can do:
  • Build a shear large amount of units, each one will contribute heavily to the formula.
  • Keep a high stockpile of gold. You need 10,000 gold for it no longer to weigh on the formula anymore.
  • Give promotions to your units! This doesn't weight that heavily but it does help!
  • Upgrade your units (as in from Crossbowman to Gatling Guns)!
  • Keep your units at high health! As shown above, a half health unit will only count as half a unit to the AI.
Notes about military strength:
  • If the AI considers your strength IMMENSE, POWERFUL, or STRONG, they will NOT want to initiate open borders with you.
  • This is NOT the only determining factor on whether or not an AI thinks its winning a war with you. This is determined by also calculating your Economic Strength, how much damage is inflicted upon us, and how much damage is inflicted upon them (I might make another thread about this because it seems really important), and how long we've been at war.
  • This is also run on City-States. Their value is added to your threat value when the AI determines if it wants to DoW on you.
  • A high military value will make the AI more likely to respect your wishes for them not to settle next to you.

If you want to get the AI to not settle near you, the best way to do this is:
  • Have them Afraid (always yes)
  • Make sure they're not hostile (always no)
  • Make sure you're not unforgiveable (always no)
  • Have them not be an expansive civ
  • Have an enormous military advantage compared to them
  • Be incredibly military aggressive towards them.
  • And then finally a number is compared to a random number (go figure) and this RNG determines whether they say yes or no!
To have a military aggression score, you must:
  • Be in the AI's line of sight (AI does not cheat to see where your units are)
  • Be at their home front
  • Don't be near a unit of a Civ that you're at war with (this doesn't count as aggressive toward that civ)
  • Don't be in your territory (it gets halved for each unit in your own territory, the AI thinks you're defending yourself)

THIS IS FOR CIVILIZATION V.
This is taken from CvDiplomacyAI.cpp, CvUnit.cpp and CvPlayer.cpp.
Single unit's power = ((Power * (promotionLevel0.3 )) * Current Health) / Max Health.
The game's formula to calculate a unit's power (different than strength) is complicated. In general, it's this:
melee: ((combat1.5 * move0.3) / 2 (ONLY IF THIS IS A SUICIDE UNIT) + 4000 (IF THIS UNIT CAN NUKE) + Promotion bonus)
ranged: ((ranged1.45 * move0.3) / 2 (ONLY IF THIS IS A SUICIDE UNIT) + 4000 (IF THIS UNIT CAN NUKE) + Promotion bonus)

The promotion bonus is stupidly complicated and annoying. Essentially it tries to take a percentage of the bonus each promotion gives a unit and adds and subtracts based on their value. In most cases it will only vary the +/- by a small amount. You're better off calculating each unit individually then posting the code. In general, the game attempts to group every unit's characteristics together to determine it's overall worth.

Let's take a Warrior who is level 2 (30 xp) and half health.
((27.86 * (20.3 )) * 50) / 100 = ((8 * (1.23)) * 50) / 100 = 9.85 * 50 / 100 = 492.5 / 100 = 17.15 Total Power
The 27.86 comes from the revised formula above.


Relevant code:
Spoiler :
int CvUnit::GetPower() const
{
VALIDATE_OBJECT
int iPower = getUnitInfo().GetPower();
//Take promotions into account: unit with 4 promotions worth > ~50% more
iPower = int((float) iPower * pow((double) getLevel(), 0.3));
iPower *= GetCurrHitPoints();
iPower /= GetMaxHitPoints();
return iPower;
}
How to calculate player's current military might:
TotalUnitPower = Add every unit's power together, divide the unit's power by half if it's a naval unit.
GoldMultiplier = 1 + (sqrt(YourCurrentGold) / 100)
GoldMultiplier cannot be higher than 2 (will only happen if you have 10,000 gold).
Calculating might formula:
Total Might = (TotalUnitPower * GoldMultiplier).
Let's assume you have 2500 gold in your treasury, then the multiplier becomes 1 + (sqrt(2500) / 100) = 1 + (50/100) = 1.5.
If you then had 235 total unit power, the final might value is: 352.5.
Relevant code:
int CvPlayer::calculateMilitaryMight() const
{
int rtnValue = 0;
const CvUnit* pLoopUnit;
int iLoop;

for(pLoopUnit = firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = nextUnit(&iLoop))
{
// Current combat strength or bombard strength, whichever is higher
int iPower = pLoopUnit->GetPower();
if (pLoopUnit->getDomainType() == DOMAIN_SEA)
{
iPower /= 2;
}
rtnValue += iPower;
}

//Simplistic increase based on player's gold
//500 gold will increase might by 22%, 2000 by 45%, 8000 gold by 90%
float fGoldMultiplier = 1.0f + (sqrt((float)GetTreasury()->GetGold()) / 100.0f);
if(fGoldMultiplier > 2.0f) fGoldMultiplier = 2.0f;

rtnValue = (int)(rtnValue * fGoldMultiplier);

return rtnValue;
}
The AI always considers you to have at least 30 strength, so add this to the military might value. So in the above example, you now have 382.5 strength.
Now the AI takes a ratio:
Military Ratio = (TheirMilitaryMight) * 100 / OurMilitaryStrength
If we (the AI) have 250 strength and they (the opponent (human or AI)) have 500 strength, then the ratio is 200, if we have 500 strength and they have 250 strength, the ratio is 50.
Now the AI does checks based on this ratio. Keep in mind if one if is satisfied the ones below it aren't, so they can't be both POWERFUL and STRONG, only one.
If ratio > 250, opponent is IMMENSE
If ratio > 165, opponent is POWERFUL
If ratio > 115, opponent is STRONG
If ratio > 85, opponent is AVERAGE
If ratio > 60, opponent is POOR,
If ratio > 40, opponent is WEAK,
If it's less than that, opponent is PATHETIC
And that's how the AI determines its military strength vs. yours!
void CvDiplomacyAI::DoUpdateOnePlayerMilitaryStrength(PlayerTypes ePlayer)
{
CvAssertMsg(ePlayer >= 0, "DIPLOMACY_AI: Invalid Player Index. Please send Jon this with your last 5 autosaves and what changelist # you're playing.");
CvAssertMsg(ePlayer < MAX_CIV_PLAYERS, "DIPLOMACY_AI: Invalid Player Index. Please send Jon this with your last 5 autosaves and what changelist # you're playing.");

StrengthTypes eMilitaryStrength;

int iBase = /*30*/ GC.getMILITARY_STRENGTH_BASE();
int iMilitaryStrength = iBase + GetPlayer()->GetMilitaryMight();

int iOtherPlayerMilitary;
int iMilitaryRatio;

if(IsPlayerValid(ePlayer, /*bMyTeamIsValid*/ true))
{
// Look at player's Military Strength
//if (GetPlayer()->GetMilitaryMight() > 0)
{
iOtherPlayerMilitary = GET_PLAYER(ePlayer).GetMilitaryMight() + iBase;
// Example: If another player has double the Military strength of us, the Ratio will be 200
iMilitaryRatio = iOtherPlayerMilitary* /*100*/ GC.getMILITARY_STRENGTH_RATIO_MULTIPLIER() / iMilitaryStrength;
}
//else
//{
// iMilitaryRatio = /*100*/ GC.getMILITARY_STRENGTH_RATIO_MULTIPLIER();
//}

//iMilitaryStrength += iMilitaryRatio;

// Now do the final assessment
if(iMilitaryRatio >= /*250*/ GC.getMILITARY_STRENGTH_IMMENSE_THRESHOLD())
eMilitaryStrength = STRENGTH_IMMENSE;
else if(iMilitaryRatio >= /*165*/ GC.getMILITARY_STRENGTH_POWERFUL_THRESHOLD())
eMilitaryStrength = STRENGTH_POWERFUL;
else if(iMilitaryRatio >= /*115*/ GC.getMILITARY_STRENGTH_STRONG_THRESHOLD())
eMilitaryStrength = STRENGTH_STRONG;
else if(iMilitaryRatio >= /*85*/ GC.getMILITARY_STRENGTH_AVERAGE_THRESHOLD())
eMilitaryStrength = STRENGTH_AVERAGE;
else if(iMilitaryRatio >= /*60*/ GC.getMILITARY_STRENGTH_POOR_THRESHOLD())
eMilitaryStrength = STRENGTH_POOR;
else if(iMilitaryRatio >= /*40*/ GC.getMILITARY_STRENGTH_WEAK_THRESHOLD())
eMilitaryStrength = STRENGTH_WEAK;
else
eMilitaryStrength = STRENGTH_PATHETIC;

// Set the value
SetPlayerMilitaryStrengthComparedToUs(ePlayer, eMilitaryStrength);
}
}
 
Top Bottom