1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Military power score.

Discussion in 'Community Patch Project' started by ridjack, Jul 30, 2019.

  1. ridjack

    ridjack Chieftain

    Joined:
    Mar 12, 2017
    Messages:
    446
    One of the most common pieces of advice tossed out there is to keep your military at peak strength as much as possible so you won't be perceived as weak and get declared on constantly. I'm sort of wondering how y'all manage to do this on non-Authority games?

    Reason I'm asking is that on my current game with Rome, with Authority, staying at or near my unit cap with Barracks, Armories, Walls, Castles and Stables(all of the +supply buildings I currently have access to) with more cities than any civ I've currently met and keeping my units (mostly) up to date I've struggled to get above the halfway mark for the Soldiers category in Demographics. Now I'm up to #4/16 and still climbing; but again, this is going full warmonger.

    In my peaceful Iroquois game that had something like twelve cities, with the most techs and same criteria as above (full supply, always up-to-date etc etc), I don't think I ever went above #12/16 and spent the entire game in a round robin of getting declared on by the entire world, especially my three neighbors. As I was trying to play Diplomatic, this made my life very difficult and eventually caused me to abandon that game out of frustration.

    So am I doing something wrong? Is there something I'm missing?

    EDIT: King difficulty, Tectonics map, all-random terrain settings, Large size, 16 civs.
     
  2. Bhawb

    Bhawb Chieftain

    Joined:
    Nov 11, 2018
    Messages:
    498
    The AI looks at more than just raw military, but also how close that military is to certain borders, how much they have to gain from declaring on you vs how much they'll lose, diplomatic modifiers each way, etc. Military power definitely matters as part of the calculation and it is usually a good idea to keep a fully updated military, but usually your best bet is to push for a very friendly relationship with one of your neighbors (and whoever they are friends with), into Defensive Pacts and fighting wars together.

    Usually if I'm getting chain-declared on its because I'm doing too well, forward settled too much, being too aggressive militarily, or due to being pulled in by Defensive Pacts or people being paid to war me. Even when I was Songhai with full military score and right at the peak of Mandekalu military, #1 in the game right before any offensive wars I had 4 of 7 AI at war with me. Sometimes AI gonna AI.
     
  3. CrazyG

    CrazyG Warlord

    Joined:
    Oct 14, 2016
    Messages:
    4,229
    Location:
    Beijing
    Military score is adjusted according to your number of cities. In theory, this is smart because an empire with more cities would need more soldiers to guard the entire realm. In practice, I think it is kind of dumb, when I have like 4 cities I tend to avoid war all game and have a high military score. When I have 15 cities and the world's strongest army I get AIs with like two cities that think they can fight me (they often have more score from military than I do).
     
    Revolutionist_8 and vyyt like this.
  4. ridjack

    ridjack Chieftain

    Joined:
    Mar 12, 2017
    Messages:
    446
    That actually explains a LOT. I was wondering why civs I ground into irrelevance in the medieval Era feel like they can get uppity when I have bomber planes and nukes.

    In my Iroquois game, I had a full fighting army on each of my three main borders, plus a mobile strike force in the center because I was the Iroquois and my entire island was roads. Never stopped any of them, nor any of the other twelve civs from declaring on me because a black cat crossed their path or something.
     
    Last edited: Jul 30, 2019
  5. Stalker0

    Stalker0 Baller Magnus

    Joined:
    Dec 31, 2005
    Messages:
    5,052
    I think the concept is sound it just probably needs some adjustment.
     
    Revolutionist_8, vyyt and CrazyG like this.
  6. CrazyG

    CrazyG Warlord

    Joined:
    Oct 14, 2016
    Messages:
    4,229
    Location:
    Beijing
    I think the AI should just look at if they have allies when considering fighting a bigger civ. If I'm at war with just one guy, the fact that I have other borders isn't a very big deal.
     
  7. CrazyG

    CrazyG Warlord

    Joined:
    Oct 14, 2016
    Messages:
    4,229
    Location:
    Beijing
    So a rant about this from my current game. I have 9 cities, including Mongolia's capital, I am one unit short of my supply cap. As I have just annexed his capital, and taken a peace treaty where he pays me, it is rather clear that I am stronger than Mongolia, yes? I can count his entire army, I clearly have more units, 6 of which are horsemen, his strongest are spearmen.

    Well I'm still last in the soldiers demographic, and I can't pledge to protect city states. I get a total of 8 points towards tributing city states from my overall military power. Mongolia is able to annex one of my allied city states when the war ends. This is really stupid.

    Similarly, I don't think I've used a pledge of protection successfully in years. Even if I am able to make one, it gets put in jeopardy once I start settling cities, and if it fades, you lose influence.
     
  8. ridjack

    ridjack Chieftain

    Joined:
    Mar 12, 2017
    Messages:
    446
    This sounds very similar to the array of issues I've been having. Sounds worth putting up on GitHub, but I'm not sure precisely what to say, and I don't have any examples or saves to offer at the moment.
     
  9. CrazyG

    CrazyG Warlord

    Joined:
    Oct 14, 2016
    Messages:
    4,229
    Location:
    Beijing
    Bumping this thread
     
  10. balinte

    balinte Chieftain

    Joined:
    Jul 27, 2016
    Messages:
    68
    Wow thats ****ed up imo
    Military score should not be calculated based on units/ the vastness of your territory, but simply based on your units.

    And then the AI declaring war on you should not be based on your military score.
     
    XplosiveLun likes this.
  11. Revolutionist_8

    Revolutionist_8 Chieftain

    Joined:
    Jan 30, 2016
    Messages:
    395
    Location:
    Hungary, Earth, M.W. Galaxy
    Well, that explains why I can't Pledge to protect CS-s, even with 21 Cities and like 50 Units in early Industrial era and with 2 Vassals :D

    I agree with @Stalker0 , this should be adjusted a bit.
     
    jdevo likes this.
  12. ilteroi

    ilteroi Chieftain

    Joined:
    Mar 11, 2006
    Messages:
    313
    retry with the latest version. raw strength now is scaled with 1 / sqrt(ncities + 3), not 1 / ncities as before. should be better.
     
  13. SpankmyMetroid

    SpankmyMetroid Chieftain

    Joined:
    Jun 22, 2016
    Messages:
    217
    Are promotions factored into score (or the level of units to put it another way)? It’s really the only reason I can think of why I see AI with inflated numbers on high difficulties since they start with a bunch of xp. I play Immortal and struggle to get in the top 60% of global power for protection and bullying when playing domination, always have. It’s ridiculous seeing my army at equal score when I’m staring down the last city of the civ I’m beating up. Unless they have 5 scouts off exploring, I can literally count how my army outnumbers theirs.

    It’d be nice if the black box of military score was revealed.
     
    Last edited: Aug 18, 2019
  14. ilteroi

    ilteroi Chieftain

    Joined:
    Mar 11, 2006
    Messages:
    313
    ok, here you go. the military score depends mainly on the sum of the "power" of all your units. the second input is the number of cities you control.

    unit power is defined as

    [PRE]int CvUnit::GetPower() const
    {
    //Base value
    int iPower = getUnitInfo().GetPower();

    //What is this about?
    if (getUnitInfo().GetRangedCombat() > getUnitInfo().GetCombat()) {
    iPower = iPower * GetBaseRangedCombatStrength() / getUnitInfo().GetRangedCombat();
    }
    else if (getUnitInfo().GetCombat() > 0) {
    iPower = iPower * GetBaseCombatStrength() / getUnitInfo().GetCombat();
    }

    //Take promotions into account: unit with 4 promotions worth ~50% more
    int iPowerMod = getLevel() * 125;
    iPower = (iPower * (1000 + iPowerMod)) / 1000;

    //Scale by health
    iPower *= GetCurrHitPoints();
    iPower /= GetMaxHitPoints();

    return iPower;
    }
    [/PRE]

    whether all that makes sense or not, i don't know. if you have better ideas, i'm open to suggestions.
     
    balinte and CrazyG like this.
  15. SpankmyMetroid

    SpankmyMetroid Chieftain

    Joined:
    Jun 22, 2016
    Messages:
    217
    Thanks ilteroi. I assume the iPower value is just multiplied by 1 / sqrt(ncities + 3) for total score, or are there other mods as well?

    My gut would be to tweak the iPowermod down a tiny bit, especially early game with no XP giving buildings you are at a massive disadvantage trying to keep up in score with the AI even if you just churn out units due to all the free promotions they get. I know that's the nature of the beast on higher difficulties, but it also leads to awkward situations where the AI will try to fight you when they don't stand a chance. Two other suggestions I can make is maybe there can also be a small modifier for possessing a GG/GAdm (with extreme diminishing returns, ex: a flat value like 1k * (1+ (logx), if x =/=0), since I assume CS from those modifiers isn't taken into account. And Unique Units could have a small multipler as well (since they typically have high level or unique promotions already slapped on or even unique promotions entirely, a level one Mandekalu cavalry is miles better than a level one horseman that is more apparent than just the difference in CS). I remember reading on the forum that the AI are aware of the eras they have unique units available and consequently become more aggressive (so this might be double dipping) but this can also value citystate gifts the AI get more appropriately (and also continue to value UU's that haven't been upgraded yet even if they're obsolete).

    I also really appreciate how health is factored in so the AI know when to backstab you if you're busy on another front.
     
    Last edited: Aug 18, 2019
  16. Omen of Peace

    Omen of Peace Chieftain

    Joined:
    Mar 22, 2018
    Messages:
    243
    Gender:
    Male
    The scale for promotions could be quadratic with a slower start but similar values for level 8+ (level 8 = +100% currently)
    e.g.
    iPower = 10 * iPowerMod * ( iPowerMod + 5 )
    that's
    +6% instead of +12.5% for level 1
    +36% instead of +50% for level 4
    +104% instead of +100% for level 8

    (Actually, IMO it would be ideal if the AI bonus XP had some era scaling, so it could start lower but reach higher in late game, but that's a different topic: it would address Metroid's concern but would also have an impact on difficulty levels.)
     
  17. Bhawb

    Bhawb Chieftain

    Joined:
    Nov 11, 2018
    Messages:
    498
    The formula is definitely broken. I have 76 military supply, with the most advanced military in the world, I objectively should have the scariest army since I have 2 vassals (Monte and Attila on top of that), and atm I have airplanes while no one else does, yet I'm 5th in soldiers above my two vassals and Venice, because I have a ton of cities. But the reality is at some point cities don't require individual defense, my entire empire (and my vassal's) can be defended by 3 fleets and 1 land army, of which I should be the scariest. But I'm not, because of my city count, which just doesn't make sense. I wouldn't be that annoyed if not for the fact that I can't pledge for my CSes right now, which is super annoying.
     
    mikes61293 and CrazyG like this.
  18. CrazyG

    CrazyG Warlord

    Joined:
    Oct 14, 2016
    Messages:
    4,229
    Location:
    Beijing
    When this takes promotions into account, is it all promotions or just the level of the unit?
     
  19. XplosiveLun

    XplosiveLun A humble village

    Joined:
    Apr 24, 2015
    Messages:
    201
    Location:
    Hong Kong, China
    @ilteroi, can you give us a little rundown on the function?

    Should be just levels, since it is "getLevel()"

    Should we separately measure the value of each promotion? Although measuring levels is close enough, various promotions aren't exactly equal in worth. For a level 4 unit, it could either be:

    - Archer: 3 Volley + Range
    - Archer: 2 Barrage + 2 Defense

    How quantifiable is promotions such as "Logistic" (Attack twice) and "2 Cover"? Should we give an exact value to these promotions? Or should we use it to multiply the iPower score (calculated by base combat strength and levels)?

    With reference to ilteroi and Omen_Of_Peace 's model and considering only one unit, should we get something like this?

    - Spearman (11) x Level 4 (1.36) x Stalwart (1.2)
    - Spearman (11) x Level 4 (1.36) x Cover (1.1) x Cover(1.1)

    As can be seen in this example, Stalwart and cover have situational use. Covers are available eariler and good against ranged units but does not aid melee defense. Stalwart on the other hand is more well-rounded, provide defense to all attacks and give 1 more level or Drill. Maybe also separately consider the "Shock" or "Drill" promotions?
     
    CrazyG likes this.
  20. chicorbeef

    chicorbeef Warlord

    Joined:
    Dec 26, 2017
    Messages:
    1,349
    Gender:
    Male
    On a slightly different note, IIRC, I believe that AI on Immortal/Deity value a player's army much more than on lower difficulties. Like if you have the same amount of units on Chieftain as a Deity player would have, you're seen as weaker on Chieftain.

    If this is true...do you think this could be a balance concern for lower difficulties? I suppose this is supposed to be balanced out by smaller AI armies on lower difficulties but I noticed that alot of posts about extreme AI aggression are about lower difficulties (like this one: https://forums.civfanatics.com/threads/aggressive-ai.645329/ (yeah I know it's old but still) or this one on Reddit: https://www.reddit.com/r/civvoxpopuli/comments/cio8jj/this_mod_minus_ai/).
     

Share This Page