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

Is there any logic to an AI DoW?

Discussion in 'Civ4 - Strategy & Tips' started by marstinson, Aug 6, 2008.

  1. Dirk1302

    Dirk1302 Chieftain

    Joined:
    Oct 5, 2006
    Messages:
    3,578
    Location:
    Netherlands
    Marvellous work again Dan:goodjob:, if i'm back from my holiday i'm going to simulate some of the things you found out. I think some grouping needs to be done on the various aspects you wrote about, there are ever new things going into the equation such as military flavor (Shaka's higher than Monty's btw). In the end i think it ought to be compiled into an article for the articles section, maybe some of the equations should be translated to more readable english as not everyone 'll have looked into the sdk/xml and it's not so easy to read in this case. On the other hand it's probably very hard to explain the mechanics involved if you're not at least a bit familiar with XML or at least the guide.
     
  2. TabascoBob

    TabascoBob Chieftain

    Joined:
    Sep 23, 2005
    Messages:
    90
    Location:
    Morris County New Jersey
    I'm not going to pretend I followed all of the formulae, and I read the thread pretty quickly: the question I was hoping to see an answer to involves a DoW I received over the weekend. (I knew it was coming too, but could I have delayed it further.)

    Stalin switched from our mutual religon back to his religon, taking us from "Pleased" to "Cautious." I was researching Rocketry and did not want to spend a turn in anarchy following him over until I was done (neither religon was founded by me, and I had the same # of cities with each). I got Rocketry, and instead of switching over to Stalin's religon immediately, I founded Aluminum Co. and ended my turn.

    Stalin DoW's me. :eek:

    From what I read above, this could have been a triggering event, or it could simply have been that the timer popped on his war plan. He had no aluminum; in fact, I think I was the only one who had it (who was on speaking terms with him anyway, I hadn't checked the other continent where his blood enemies reside).

    So, my question is: did something happen that triggered the DoW and if so, what is the most likely reason? Was it:
    a) me getting Rocketry
    b) me founding Aluminum Co
    c) timer popped on his war plan
    d) me getting a) and b) above affected the calculation on his decision to go to war in a way that flipped it from the turn before
    e) purely chance

    Any thoughts on this? If I had taken the chance of switching religons to Stalin's before founding Aluminum Co., could I have avoided his DoW on that turn?
    Thanks
     
  3. DanF5771

    DanF5771 Chieftain

    Joined:
    Feb 21, 2008
    Messages:
    1,194
    Late in the game (industrial+ era) Dagger isn't a valid strategy for the AI anymore. This means that they will always enter a phase of preparation after they have chosen to start a war, so a decision for a war due to dropped relations followed by an immediate DoW is not possible (sudden DoWs can still happen but are the result of random events or diplomatic actions = bribing, AP + UN forced wars, Stalin can be bribed to DoW someone he is pleased with [those Russians...]). So I guess Stalin decided to go to war (most likely a Total War, his MaxWarRand is 100) with you at least 10 turns earlier (depending on game speed). His attitude "Pleased" towards you was not enough to prevent this (his NoWarProb for Pleased is 90). If you still have saves, you can check for WHEOOHRN. At this stage of the game the AI has spammed enough offensive units (Stalin's BuildUnitProb = 30) to pass the check if the army is ready. The only way to make him call off his war plans is to have someone else to declare on him in the meantime. A DoW can only be postponed by asking for small gifts/tributes (1:gold:) that come with a 10 turns peace treaty, but the war plans won't be changed by this. Any other actions like switching back to his religion, getting him to "Friendly" or even signing a Defensive Pact with him don't have any effect!
     
  4. Dirk1302

    Dirk1302 Chieftain

    Joined:
    Oct 5, 2006
    Messages:
    3,578
    Location:
    Netherlands
    ^Has this changed in bts compared to warlords? I'm sure in warlords if an ai had declared on you (wheeooh fase not actual dow) he'd dow you anyway even if at war with another civ, i have seen it there at least a couple of times.Indeed i haven't seen this in bts, does the code actually confirm this?
     
  5. DanF5771

    DanF5771 Chieftain

    Joined:
    Feb 21, 2008
    Messages:
    1,194
    I don't know about Warlords, but in BTS this is how it works. The relevant code is in CvTeam::declareWar:
    Code:
    [SIZE="3"]GET_TEAM(eTeam).AI_setWarPlan(getID(), ((isBarbarian() || isMinorCiv()) ? WARPLAN_ATTACKED : WARPLAN_ATTACKED_RECENT));
    
    for (iI = 0; iI < MAX_TEAMS; iI++)
    {
    	if (GET_TEAM((TeamTypes)iI).isAlive())
    	{
    		if (!GET_TEAM(eTeam).isAtWar((TeamTypes)iI) && GET_TEAM(eTeam).AI_isChosenWar((TeamTypes)iI))
    		{
    			[B]GET_TEAM(eTeam).AI_setWarPlan(((TeamTypes)iI), NO_WARPLAN);[/B]
    		}
    	}
    }[/SIZE]
    If Stalin (eTeam) plans a Total War vs me (WHEOOHRN before the DoW, GET_TEAM(eTeam).AI_isChosenWar((TeamTypes)0)==true) and I bribe Shaka to DoW him, then the code for Shaka's declaration on Stalin will have Stalin set his war plan for Shaka to WARPLAN_ATTACKED_RECENT and then call off his war plans for me (NO_WARPLAN).
     
  6. Gliese 581

    Gliese 581 Your average civ junkie

    Joined:
    Oct 11, 2007
    Messages:
    2,503
    Location:
    Sweden
    So it seems we've discovered that having a high power rating is useless unless you can get it above a treshold specific to the threatening leader (which someone should compile into a pdf :p ).
    What about dogpile wars? Won't power rating prevent other AIs from jumping in if you get attacked? Not that it matters if it's deity and Gilgamesh attack before 2000 bc.
     
  7. DanF5771

    DanF5771 Chieftain

    Joined:
    Feb 21, 2008
    Messages:
    1,194
    If I am at war with Shaka, then De Gaulle (the master dogpiler) won't dare to jump in to dogpile me as long as I can keep my power > 2/3*(Power_Shaka + Power_DeGaulle)
     
  8. Gliese 581

    Gliese 581 Your average civ junkie

    Joined:
    Oct 11, 2007
    Messages:
    2,503
    Location:
    Sweden
    Wow, that's not gonna happen. :) Getting 2/3 of Shaka's alone is impressive.
     
  9. TheMeInTeam

    TheMeInTeam Top Logic

    Joined:
    Jan 26, 2008
    Messages:
    25,027
    If you're already at war and playing even a remotely high difficulty, it's pretty well impossible to prevent a dogpiling short of diplomacy. An exception my be owning the target so hard that they ALSO fall below that threshold, and having their position make them more viable targets to the AI than you either for diplo or just border reasons.
     
  10. Gliese 581

    Gliese 581 Your average civ junkie

    Joined:
    Oct 11, 2007
    Messages:
    2,503
    Location:
    Sweden
    Again, not going to happen. :D

    Well I guess in diplomacy we trust.
     
  11. TheMeInTeam

    TheMeInTeam Top Logic

    Joined:
    Jan 26, 2008
    Messages:
    25,027
    That's not necessarily true on "not going to happen". It's quite likely if you bait an AI SoD into your territory and kill it that you are now BOTH under the threshold for an AI :backstab:. After all, it considers your power as part of its own when looking at your enemy's strength too if I understand correctly, and player power + shaka power is likely to be past the point that your enemy would have 2/3 of it. In this case, Shaka could happily stab either the player OR the player's enemy. If the enemy is closer or shaka hates him more, you could very well get a favorable dogpile. At least until feudalism where Shaka gets a vassal :cry:. War early or war overwhelming!
     
  12. Gliese 581

    Gliese 581 Your average civ junkie

    Joined:
    Oct 11, 2007
    Messages:
    2,503
    Location:
    Sweden
    But for De Gaulle to consider Shaka a more tempting target you'd have to get above 1.0 of Shaka's power. That will likely take more time than you'd have, one SOD is probably not going to cut it.
     
  13. TheMeInTeam

    TheMeInTeam Top Logic

    Joined:
    Jan 26, 2008
    Messages:
    25,027
    If shaka is stronger than France already, I don't see how that could be true.

    Let's say you're 1/2 of shaka's power, while france is 3/4 of his power. If you go to war with france, shaka looks at you and considers his + frances. You're a target for sure. He also looks at france and adds your power to his own. Shaka's power relative to france would then be 1.5 what is was originally...or double france's.

    The above scenario isn't all that implausible, and the more the 3rd party is ahead of you and your opponent, the more it's a crapshoot who the declare on - both are eligible targets independent of power considerations at that point. It then falls to diplo and other checks that make war more likely vs one than the other.

    Am I right on this Dan? Or is it different for player vs AI dow considerations?
     
  14. Gliese 581

    Gliese 581 Your average civ junkie

    Joined:
    Oct 11, 2007
    Messages:
    2,503
    Location:
    Sweden
    Yes that might be true, but the scenario given was a war with Shaka, not De Gaulle, which is a more likely scenario early on. Unless you were already preparing to attack Shaka, 0.5 of his power would be a good job on immortal. It seems to me that De Gaulle would not have to think long on which is the weaker target (although he might ultimately be wrong when you factor in strategic consideration since a human army has a decisive leadership advantage).
     
  15. DanF5771

    DanF5771 Chieftain

    Joined:
    Feb 21, 2008
    Messages:
    1,194
    Absolutely TMIT, you are right. An example:
    I have 700 ks (ks = 1000 soldiers), Shaka 1000 ks, DeGaulle 900 ks. Shaka DoWs me (what a surprise). Once in 20 turns DeGaulle looks for a dogpile opportunity.
    The power checks are:[pre]Can DeGaulle Dogpile-DoW me? 2/3*(900 + 1000) = 1266 > 700 --> yes!
    Can DeGaulle Dogpile-DoW Shaka? 2/3*(900 + 700) = 1066 > 1000 --> yes![/pre]LandTarget checks (this is the requirement which makes Dogpile Wars a rather rare occurrence!):
    Do I and Shaka have at least 1 city on Paris' landmass? Do we both have at least 8 land plots bordering France territory (those can be anywhere on the map)?
    If true, we are both valid dogpile targets for DeGaulle and he will determine the victim with the best startWarValue (number of adjacent landplots, capital proximity, borked self-closeness, scaling for attitude).
    If DeGaulle is CAUTIOUS with me and ANNOYED with Shaka it is very likely that he will DoW Shaka.
    He will not care about power ratios at this point at all!
     
  16. Gliese 581

    Gliese 581 Your average civ junkie

    Joined:
    Oct 11, 2007
    Messages:
    2,503
    Location:
    Sweden
    Thanks for clarifying Dan, your numbers shows that there is a point to having some power even if it wont necessarily stop a regular attack, however the numbers are still pretty hard to hit, especially on deity I would think, 0.7 is not a small accomplishment there. I also suspect that a Shaka who's prepared for a war will have more than 1.0/0.9 of De Gaulle's power. From your numbers it would in fact seem unlikely that De Gaulle would be in a position to be able to dogpile Shaka.
     
  17. DanF5771

    DanF5771 Chieftain

    Joined:
    Feb 21, 2008
    Messages:
    1,194
    I agree, those would be cloudland numbers for a deity game. But as TMIT said, letting Shaka suicide his monster SoD might get you somewhere.
    As long as Shaka passes his target checks, it won't matter--he will DoW Shaka. But he will probably sue for peace shortly after or capitulate after losing one city...
     
  18. GatlingGun

    GatlingGun Chieftain

    Joined:
    Feb 3, 2008
    Messages:
    273
    Location:
    Northwest USA
    I have a perhaps dumb question that may have been answered elsewhere...

    Let's suppose you compare a single modern armor unit to a single warrior.

    I'm assuming the modern armor unit counts as more soldiers than the single warrior, right? If so, does anyone know how this formula works?
     
  19. Gliese 581

    Gliese 581 Your average civ junkie

    Joined:
    Oct 11, 2007
    Messages:
    2,503
    Location:
    Sweden
    I refer you to: http://forums.civfanatics.com/showthread.php?t=163098&highlight=demographics

    Edit: From this listing we see that a modern armor is equivalent of 40 warriors in power rating.
     
  20. Yamps

    Yamps Chieftain

    Joined:
    Aug 30, 2007
    Messages:
    2,728
    Location:
    Zagreb, Croatia
    Awesome thread! :goodjob:

    I also have some questions:

    What about war declarations when you don't do what they ask? I guess that iDemandRebukedSneakProb and iDemandRebukedWarProb have sth to do with that. There is also iDeclareWarTradeRand, 40 for everybody. How does it work exactly?

    Thanks in advance! :)
     

Share This Page