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

They need to hotfix AI agression now

Discussion in 'Civ5 - General Discussions' started by godman85, Jul 11, 2013.

  1. Aristos

    Aristos Lightseeker

    Joined:
    Dec 11, 2001
    Messages:
    3,575
    Gender:
    Male
    Location:
    Deep inside...
    In the light of the newly released DLL source and the piece of code above, I wonder if we should start a new thread? The discussion here will become mixed now, with some people answering to questions/speculations pre-DLL code that are probably not relevant anymore... yet if we start a new thread, how to title it so that the mods do not end up merging again? I fear that important piece of information will be buried under dozens of now-obsolete questions/answers...
     
  2. pilot00

    pilot00 King

    Joined:
    May 21, 2013
    Messages:
    917
    They do know however that they have a numerical superiority. So do you in fact, since the human can access the advisers and the demographics it should be safe to consider that the AI does the same. They do know the probability of you buying units (cash) and they do know roughly or exactly (scouting if you have open borders) how many cities and their position you have. In other words they are capable of formulating a scenario of weather they can win or not on pure numbers and GPT that is. Yet they don't, not anymore at least, they did in G&Ks

    @Aristos, while this code is good find I have yet to experience the rationale behind it. What I mean is this: First of all once in a war the AI doesn't loose its caravans, those are returned to the pool to be reassigned. Thereby it can still trade, wheather the income is more or less is a consideration to be taken into the context of gain though. Can it win the war and severly weaken a competitor or not? Is it worth the sacrifice? I think those considerations are not taken into account.
    Another thing that buggers is me, is why would the AI would DoW Morocco (as an AI) for example when it more lucrative to maintain trade relations with it and consider only its trade relations with the human player?
    And how is it that in early wars only the human is exempt?

    In other words: The presence of this piece of code, doesn't mean that there isnt a large flaw in the logic on how the code (end result) itself is implemented.
    Granted it will never be perfect, but it can be better than implementing its GPT and trade cost only as variables. If anything it reads more of a rush job.
     
  3. dexters

    dexters Gods & Emperors Supporter

    Joined:
    Apr 23, 2003
    Messages:
    4,182
    Gender:
    Male
    Location:
    Canada
    Pretty sure the Ai will lose their caravans if they Dow, just like human players. Only time caravans are returned is if you are the victim of aggression
     
  4. Aristos

    Aristos Lightseeker

    Joined:
    Dec 11, 2001
    Messages:
    3,575
    Gender:
    Male
    Location:
    Deep inside...
    I do not see any differentiation in the code regarding human or AI... so, that block of code acts exactly the same for any player in the game. Granted, there are other modifiers (plenty) that affect the "Go To War" weight, but I couldn't see any big change in those from G&K... I might have overlooked something, because I quickly went over the file, and the file is huge (and there are others), so the whole package calls for a thorough investigation for the curious.

    What I wanted to show if that there is a rationale behind what some are seeing, and that it is WAD. Not a BUG, in other words. We can continue the debate now in terms of how good/precise/appropriate the design decision was, and how to change it if necessary. In other words, I wanted to kill the whine and move this to a more rational ground.

    Also, see the comments "To Do: constant/XML", clearly pointing to an eventual extraction of some of the components of the modifier from the hard code --> modding. I wonder why the did not do that right from the beginning... I am sure it will come with the first patch, especially now that they are seeing some reactions.
     
  5. Gaizokubanou

    Gaizokubanou Warlord

    Joined:
    Jan 15, 2006
    Messages:
    253
    Does that 'sanity check' means that civs that are in the negative economy will never go to war with civs that it's trading with? Or does it just reduces the likelihood of DoW by some significant amount?

    Also did standard game on King and similar stuff, no war til late renaissance. By industrial things finally kick off but that's still rather absurd especially given that my game had both Huns and Zulu in it. I even killed Germany in medieval to instigate some international turmoil but nothing... razed cities, capped Berlin but everyone still loved me. Huns and Zulu were busy denouncing Siam and Shoshone since ancient era but it took industrial era for them to start kicking some asses.
     
  6. eric_

    eric_ Emperor

    Joined:
    Nov 29, 2005
    Messages:
    1,725
    Location:
    Riverdale, MD
    I mean, I couldn't possibly address all permutations of scenarios that lead to a lack of war against the human player. The overall point is, there seem to be a LOT of new, interrelated, dynamic elements at play, and I think a lot of them can conspire to make war an unfavorable choice. In many cases, this elements may have little to do with what any one player (including the human player) has going on at any given time.
     
  7. Aztecopi

    Aztecopi Warlord

    Joined:
    Dec 26, 2012
    Messages:
    115
    Gender:
    Male
    Location:
    Finland
    Am I just really lucky or are you all lying, I have had tons of wars in my two games I've played (stupid Bismarck and Al-Mansur/Ashurbanipal/Dandolo)
     
  8. Buccaneer

    Buccaneer Deity

    Joined:
    Nov 2, 2001
    Messages:
    3,562
    I wonder if there are scenarios in a standard game where the AI can win in turns 225-300 or they now being forced to delay or extend the game?
     
  9. eric_

    eric_ Emperor

    Joined:
    Nov 29, 2005
    Messages:
    1,725
    Location:
    Riverdale, MD
    It's just an algorithm to determine exactly what the blow to the AI will be due to a loss in trade incurred by DoWing a given civ. How heavily the AI weighs the results of the calculation is handled by another algorithm elsewhere in the code.
     
  10. pilot00

    pilot00 King

    Joined:
    May 21, 2013
    Messages:
    917
    Oh, I never said it was a bug :)

    Problem is too many 'coincidences' mine is the current 4th coincidence in a row.

    It either is a lying infection or we secretly met in a dark cellar before the release and decided to flak the new game on this platform :lol:

    EDIT: Forgot to say this: Even if that piece of code explains somethings it adds more questions. In my previous game I was sandwiched between Rome, Greece, Morocco and Askia. I had three archers till the Renaissance and three cities. I was trading both with Marocco and Rome. Rome and Greece were friends, Askia was a non issue (got gobled up by Morocco except one city) and Morocco after the war with Askia had no significant (compared to the other two).
    The trades tab informs me that Caesar gained around 10 gpt from our trade routes. Add to this the fact that he hated me (denouncement on my part), my lack of army (he had a sizable army of rifles and cannons), and a couple other of negative modifiers. His income was 268gpt, he would certainly not loose any income from me.
    Unto my experience from the above and another three games, it appears that the AI is either hard-coded somewhere to keep a more passive stance towards the human, or there is something else we are missing.
     
  11. dexters

    dexters Gods & Emperors Supporter

    Joined:
    Apr 23, 2003
    Messages:
    4,182
    Gender:
    Male
    Location:
    Canada
    The common factor could be your playstyle.

    That the AI takes more into account before declaring war is I think well established by this point, and backed up empirically.

    The point remains quite open whether it needs to be fixed and in what direction.
     
  12. eric_

    eric_ Emperor

    Joined:
    Nov 29, 2005
    Messages:
    1,725
    Location:
    Riverdale, MD
    To break down the crucial part of the code, here's how I read it:

    Code:
    // sanity check - if we will go negative from war with this player, don't go to war
    This threw me at first, as it sounds like it's staying, if revenue goes negative, don't war. But, I'm pretty sure it's saying something else. See *** below

    Code:
    int iGPT = GetPlayer()->calculateGoldRate();
    int iDeltaGPT = iGPT - iCurrentTradeValue;
    iGPT = player's overall gold per turn
    iDeltaGPT = the change in gold per turn if the AI goes to war.

    Code:
    if (iGPT >= 0 && (iDeltaGPT < 0))
    {
    viApproachWeights[MAJOR_CIV_APPROACH_WAR] += iDeltaGPT;
    }
    This is the crux of it all. If GPT is not negative AND if iDeltaGPT IS negative (i.e., going to war will reduce gold), then add iDeltGPT to viApproachWeights[MAJOR_CIV_APPROACH_WAR] (which I take to be a constant for a given civ's likelihood to war with a major civ). If iDeltaGPT is negative, then adding it to viApproachWeights[MAJOR_CIV_APPROACH_WAR] will cause the latter to be reduced.

    My guess is the sanity check means *** If adding iDeltaGPT (reduction in GPT due to DoW) to viApproachWeights[MAJOR_CIV_APPROACH_WAR] (Civ's likelihood to war) causes the latter to go negative, then don't go to war.

    The viApproachWeights[MAJOR_CIV_APPROACH_WAR] is very likely different from civ to civ, and, iirc how flavors are handled in Civ V, even different for the same civ from one roll to the next...so that comes to bear on how much of a drop in GPT it takes to deter a DoW in any given situation.
     
  13. dexters

    dexters Gods & Emperors Supporter

    Joined:
    Apr 23, 2003
    Messages:
    4,182
    Gender:
    Male
    Location:
    Canada
    ^ Right, warmongers with a higher propensity to go to war with have a higher viApproachWeights[MAJOR_CIV_APPROACH_WAR] and thus the change in gpt may not be enough to overcome the high propensity for war and it could still return a positive result for Dow most of the time.

    If I understand this correctly, a potential fix could then be to bump up that constant for the warmongers as an easy fix, assuming all people care about is seeing early wars or being afraid of one. Might be interesting if someone increased this value for some Civs and see if we get a more varied early game.
     
  14. pilot00

    pilot00 King

    Joined:
    May 21, 2013
    Messages:
    917
    First game: Cultural passive. Expand to four cities.
    Second game: Domination spree.
    Third game: middle ground. Both conquests of opportunity and expansion, a little bit of everything.
    Fourth game: Undecided yet, but I think Ill give war another try.

    So there is not a single play-style. As are not the maps all were randomly generated (except size huge), including the CiVs. First time in my life Cathy was honest and Monty didn't try to destroy me.

    We don't disagree that the AI does take more impute neither that this is good. Just what the heck is it doing with this input in relevance to the human player is what is cause for concern.

    It pretty evident that when the AI is incapable of making the most beneficial decision, whether this is war or another subject for its plans and attempts at victory, then there is a big problem. More-so, if its programmed to follow a single play-style predetermined at the start of the game. It should be able to access the situation and adapt. Do what it is favorable at any given time.

    EDIT: Just seen Aristos new post. If I get it right, whenever the GPT earns are reduced due to war the AI, thinks its not cost effective (no matter the amount) and gets a don't war inclination right? Well that would explain the semi permanent piece, but I still fail to see why it would declare wars with other AIs that will make it loose more capital (gpt) than the human player.
     
  15. eric_

    eric_ Emperor

    Joined:
    Nov 29, 2005
    Messages:
    1,725
    Location:
    Riverdale, MD
    "If I understand this correctly, a potential fix could then be to bump up that constant for the warmongers as an easy fix, assuming all people care about is seeing early wars or being afraid of one. Might be interesting if someone increased this value for some Civs and see if we get a more varied early game."

    That's my reading, dexters. But, I'm not 100% sure how to interpret viApproachWeights[MAJOR_CIV_APPROACH_WAR]. The all caps of MAJOR_CIV_APPROACH_WAR implies a constant, which kind of throws me off. My guess is that this "sanity check" method is called on an object representing a civ that is rolled in a given game, and not some game level value for that civ.

    If that's the case, then there'd have to be a game-level value for each civ that is then modified on game roll. That game-level value would be the one you'd have to change to play around with it. You could probably also find and reduce the effect of the algorithm that modifies the game level value for each roll.

    But, this is all, er, "reverse engineered" in my head...I'd need to pick apart the code or get confirmation from someone who has...it also assumes that Civ V still has base characteristic values for each civ and then allows those characteristic values to go slightly higher or lower on a given roll.
     
  16. eric_

    eric_ Emperor

    Joined:
    Nov 29, 2005
    Messages:
    1,725
    Location:
    Riverdale, MD
    More specifically, if the loss in GPT reduces below 0 that particular AI's likelihood to war given a particular roll for a particular game, it won't war. So, it's an interaction between cost effectiveness of going to war and the AI's "natural inclination" to go to war, all other things being equal.
     
  17. dexters

    dexters Gods & Emperors Supporter

    Joined:
    Apr 23, 2003
    Messages:
    4,182
    Gender:
    Male
    Location:
    Canada
    @eric_ my read is that different Civ will have their own MAJOR_CIV_APPROACH_WAR with warmongers having higher values.

    So the change would have to be on the table of values, and not 1 value representing all Civs.

    Hence my suggestion that it might be interesting to see if early game changes if someone bumped up the values for all the warmonger Civs and see if we get a result more consistent with pre BNW games.

    Sorry if that wasn't clear.
     
  18. eric_

    eric_ Emperor

    Joined:
    Nov 29, 2005
    Messages:
    1,725
    Location:
    Riverdale, MD
    I think we're saying the same thing dexters. I was just getting into the nitty gritty about which constant is being referred to in that algorithm...it would have to be the value applied when a civ is rolled, not the hard-coded base value, unless there is no longer any variation in civ characteristics from one game to the next. In my earlier post "game level value" meant the base value for each civ, not a value shared by all civs.

    At any rate, there's probably an XML file somewhere with the related base value for each civ...that's what would need to be modified to test this.
     
  19. Buccaneer

    Buccaneer Deity

    Joined:
    Nov 2, 2001
    Messages:
    3,562
    It's not just the approach to war but the approach to the other victories as well - or have we concluded the AI is not being passive and is being aggressive in those and war is the only issue?
     
  20. dexters

    dexters Gods & Emperors Supporter

    Joined:
    Apr 23, 2003
    Messages:
    4,182
    Gender:
    Male
    Location:
    Canada
    It's my impression the most complaints are around lack of war, specifically early war.

    My own reservations is that Warmonger Civs with early strong UUs that used to perform decently chewing up neighbours may be slightly disadvantaged if they don't go to early wars often enough.

    But that's based on a few sample sizes from my own games only. And it's not like Montezuma or China were reliable powerhouses in my pre-GNK games anyways.
     

Share This Page