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

Buffed AI for BNW

Discussion in 'Civ5 - Mod Components' started by glider1, Jul 28, 2013.

  1. joncnunn

    joncnunn Senior Java Wizard Moderator

    Joined:
    Mar 17, 2008
    Messages:
    8,621
    Location:
    Missouri
    Changing
    Code:
    UPDATE HandicapInfos SET HappinessDefault = 9;
    to
    Code:
    UPDATE HandicapInfos SET HappinessDefault = 12 WHERE Type = 'HANDICAP_AI_DEFAULT';
    would help opening game AI without really impacting later on. (This is the control for the flat constant, the others are percentage modifiers to population and/or number of cities)

    To avoid the mod changing human level handicaps on Warlord & below:

    Code:
    UPDATE HandicapInfos SET NumCitiesUnhappinessMod = 100;	
    UPDATE HandicapInfos SET PopulationUnhappinessMod = 100;
    UPDATE HandicapInfos SET PolicyPercent = 100;
    UPDATE HandicapInfos SET ResearchPercent = 100;
    
    should also have that where clause restricting it to the AI Default Handicap.

    Edit: That happiness bonus helped the AI so much that to keep the AI from snowballing out of control on Immortal I've changed

    Code:
    UPDATE HandicapInfos SET AIPerEraModifier = -7 WHERE Type = 'HANDICAP_IMMORTAL';
    
    back to
    Code:
    UPDATE HandicapInfos SET AIPerEraModifier = -6 WHERE Type = 'HANDICAP_IMMORTAL';
    
    Deity's will also need reduced.
     
  2. glider1

    glider1 Deity

    Joined:
    May 29, 2006
    Messages:
    2,834
    Location:
    Where animals hop not run
    Interesting that all you changed was AI default happiness from +9 to +12 and that has caused you to have to change the per-era-modifier. The conclusion seems to be that the effect of the happiness change is longer term than was expected. That is why I decided to test making the per-era-modifier adaptive. If anyone is interested, I'm testing a simpler version of this mod where I leave the handicapping as per the default game, but adaptively change the per-era-modifier (PEM) in game. I think it might be a better solution because it has less unintended consequences.

    In my current game, I started on emperor, but the AI has shifted up to deity PEM since I got to the renaissance. I played as Babylon and pushed the science as hard as I could but the Iroquois are still three techs ahead. The good news is that the PEM does seem to have an indirect effect on the AIs tech rate.

    Let me know if you or anyone wants to try it. The version I am using contains most of the other buffed AI components, just not the handicapping nor the adaptive buff or tech funnel.

    EDIT:
    It is capable of adjusting a warlord start up to deity (and beyond) and it does so quite quickly. It never lowers the PEM below the current difficulty level.

     
  3. joosegoose25

    joosegoose25 King

    Joined:
    Aug 9, 2014
    Messages:
    639
    What criteria determines whether or not, and how much, the PEM gets adjusted?
     
  4. glider1

    glider1 Deity

    Joined:
    May 29, 2006
    Messages:
    2,834
    Location:
    Where animals hop not run
    The criterion so far for per-era-modifier (PEM) is this:

    Equation:
    MyPEM = MyPEM + (avg number of techs of all civs except me - my number of techs)

    Example for emperor:
    MyPEM = -3 + (52 - 54)
    MyPEM = -5 (Deity)

    In other words:
    If you are exactly on average number of techs, your PEM stays the same as per your difficulty level. It is never allowed to go lower than your difficulty but can go as high as -10.

    In practice, if you start at too low a difficulty level for your ability, you can easily manipulate your PEM by controlling your tech rate which feels "gamey". If you start at too high a difficulty, you cannot control your PEM because the other AIs will be out-teching you regardless.

    I think what it does is very interesting. First off, it takes the focus off science. You are not trying to out-tech your opponents until the end-game. It tends to make you keep great scientists in reserve to pop them at critical points in the tech tree. It also tends to make you beeline techs rather than to turtle.

    Secondly, it means that every game lasts longer (because you don't quit through it being too easy), so long as you are conservative with the initial difficulty you pick.

    It means that domination is easier (balancing the extra combat difficulty in this mod) because tech is not so important in domination and the effect of the PEM on AIs decreases the smaller the AI is.

    I think it also causes the player to consider early conquest and expansion more seriously. It is important to ensure that neighbours are sufficiently weak so that when the PEM starts to rise later in the game, your neighbours are not going to be a threat because PEM does not effect small AIs as much.

    It will take a few games to sort out exactly where the strengths and the weaknesses are, and what is the best difficulty to use relative to where you are at now.....

    I'm emperor, but I'd say prince, king, emperor are all playable, not sure which is best.
     
  5. joncnunn

    joncnunn Senior Java Wizard Moderator

    Joined:
    Mar 17, 2008
    Messages:
    8,621
    Location:
    Missouri
    So, it looks like the starting per era modifier numbers are all going back to default anyway (In Beta 13 Emperor had actually been changed to -5 and Deity changed to -10)

    An interesting thing on the default number is they skip over -1. (Prince and below is 0, King is 2)

    It's also cool that the human will get notified.

    One question though, does it also demote itself if it had earlier promoted itself if they catch up?
     
  6. glider1

    glider1 Deity

    Joined:
    May 29, 2006
    Messages:
    2,834
    Location:
    Where animals hop not run
    Yeah it does demote but not below the current difficulty (I could change that but I think it gets silly?) Interestingly, what happens is that you cannot undo the techs you have acquired. So if you push the science pedal down too hard, the AI gets to go up in difficulty and that cannot be undone until you take the foot right off the throttle pedal and wait for the AIs to catch up (which may not actually happen because the AIs can run away).

    So actually, it is still like the base game where you are trying to win in the shortest amount of turns, but the twist is that you have to manage science, not maximise science which is actually a more complex challenge than the base game that is for sure.

    I guess you could think of this idea as a variant of the base game, rather than an adaptive AI as such....

    For example, on prince the PEM = 0. So if you are actually a deity player, you could wear being roughly five techs better than the average tech rate at which point you would be playing the AI at the PEM you would normally play it at anyway.

    Likewise, if you played at deity, the mod would actually be totally turned off and play identical to normal deity, because the PEM never falls below deity and will most likely not rise above it, unless you are one of the vanilla deity players who know how to manipulate science to win on deity.

    EDIT:
    The other feature about the idea is that because it is based on average AI number of techs it means that the PEM tends to want to rise as the game goes on, getting more difficult even if you did nothing special to make it more difficult. That happens because the conquered AIs pull the average tech down over time.

    The weakness of the idea is that if you choose a really low difficulty level and drive the difficulty level up adaptively by pushing the tech throttle, you can put the AIs into suspended animation because they are playing at deity on warlord difficulty, and so if that PEM is taken away from them when you take the throttle off science, after 10 or so turns they don't know what to do with themselves with such a low PEM. I haven't seen the problem, I'm just speculating :)
     
  7. joncnunn

    joncnunn Senior Java Wizard Moderator

    Joined:
    Mar 17, 2008
    Messages:
    8,621
    Location:
    Missouri
    While that does describe human originated attacks when seeking Domination victory since they'll target the biggest threats (even with you exclude the human tactic of leaving the AI with a useless city for diplomatic reasons since some other AI will finish the job), when this is AI doing the heavy lifting against another AI, they tend to wipe out whoever is furthest behind.
     
  8. glider1

    glider1 Deity

    Joined:
    May 29, 2006
    Messages:
    2,834
    Location:
    Where animals hop not run
    Here is a stock take of every change in the mod at this point to remind myself:

    • Difficulty:
    • AI difficulty level adaptively boosted by altering the PEM and notification of change sent to player.
    • AI no free techs
      Military:
    • Human range attack both cities and units nerfed 20% and possibly further for range-3 land and sea against enemy units not cities
    • Human strength of city and units decreased by 25%
    • AI major civs (not minors or barbs) get a combat attack bonus of 25% against anything human or not.
    • Siege units start with cover promotion
    • AI gets no free promotions (must earn them)
      AI:
    • AI guards its workers better
    • City states start with a warrior that will protect their worker when it is built
    • Barbarians most likely will not capture AI settlers but will still take their workers
    • AI less likely to get involved in third party war (should I make this less strict?)
    • Reckless expansion modifier engages for both tall and/or wide
    • AI takes the nerfs to human combat into consideration when planning a war
    • Smart Mod by Ninakoru
      Gameplay:
    • If timed VC is turned on but nothing else, AI behaves as if it could win by its desired VC, and launching space ship grants points instead of ending game.

    EDIT:
    Added no free techs

    Because it is in alpha, there is currently no download for it, ask if you want to try it. I'm pretty sure it is fine however.
     
  9. glider1

    glider1 Deity

    Joined:
    May 29, 2006
    Messages:
    2,834
    Location:
    Where animals hop not run
    Yes, when playing this variant last night, I personally wanted myself or some other AI to get rid of those pesky little civs because their tech rate was so low it was pulling the average down. The Iroquois were going for domination it seemed, but the pesky little civs still hung on (india, carthage, mongolia).
     
  10. joncnunn

    joncnunn Senior Java Wizard Moderator

    Joined:
    Mar 17, 2008
    Messages:
    8,621
    Location:
    Missouri
    What I'm thinking is that the AI if already in a war should NEVER be willing to join yet another war. (Including the AI's forces are on the way to attack but they've not yet officially declared war) nor should it be asking either the player or other AIs itself to joint attack a 3rd party in this case but instead only be seeking allies against their current opponent.

    The AI is so bad at mufti-front wars its suicidal. (Even humans tend to avoid them unless they are bigger than both combined) In fact, the mod as a side effect actually makes an AI being at war with 2 different AIs at the same time even more suicidal than in base game due to the AI attack bonus.
     
  11. glider1

    glider1 Deity

    Joined:
    May 29, 2006
    Messages:
    2,834
    Location:
    Where animals hop not run
    Good idea thanks. I'll head in that direction with it. :goodjob:

    EDIT: The AI has no code for coordinating multi-front wars that I am aware of. I doubt it can send multiple operations of the same type to different fronts either.
     
  12. dhialuck

    dhialuck Chieftain

    Joined:
    Jan 7, 2008
    Messages:
    31
    Location:
    UK
    Well this is OK but maybe we should exclude far away opponents from this exclusion, as in it is ok to join a war against a far away opponent or vice versa (imagine the AI is already at war with a non-threat far away opponent and an opportunity presents itself for a joint war on a juicy neighbour) in this case the AI should take it just as a Human will!

    BTW Glider I am an active user of your mod since version 15, I am just being quiet because my main concern with the AI is its tactical and Logical choices as opposed to its technological advancement or economical output which seemed the direction this mod took.
    I am now using your beta 13 (the last one you posted) in an Emperor Game Terra Huge map and 22 players 24 city states Sparse resources as Carthage and I am in the middle ages now.
     
  13. joncnunn

    joncnunn Senior Java Wizard Moderator

    Joined:
    Mar 17, 2008
    Messages:
    8,621
    Location:
    Missouri
    The thing is if you can't express it it by either boolean logic or via math, it's not something you can teach a computer to do.
    You get a much better AI teaching it the general rule (Civ IV AI rules) and thus disallowing it from doing something that's 1 time out of a 100 good than you do allowing it to do things and (thus choosing it not only the 1 time out of 100 its good but also additional times in which its bad.)
     
  14. glider1

    glider1 Deity

    Joined:
    May 29, 2006
    Messages:
    2,834
    Location:
    Where animals hop not run
    Good to hear someone is trying this mod thanks Dhialuck. I have already got onto a bit of AI coding, but I'm doing this for entertainment, not punishment. Improving the AI is gruelling work, that needs tangible rewards (which Civfanatics does not provide). With this old fashion AI technology, working on this AI will put you in a wheel chair by age 30. It requires 1000's of hours in front of a computer screen.

    So I will do whatever I think I can code quickly and easily. This mod is primarily about giving bonuses to the AI, because that is the quickest route to an interesting game. Once that is exhausted, then move onto improving the intelligence of the AI.

    So we need *precise implementable algorithms* that you people come up with, so that I can code it quickly.

    EDIT:
    But for the mean time this mod is still at the stage of buffing the AI. Why? Because if there are only 1 or 2 people trying it out, it takes a long time to fully understand the effects of the buffs on an enjoyable game.
     
  15. glider1

    glider1 Deity

    Joined:
    May 29, 2006
    Messages:
    2,834
    Location:
    Where animals hop not run
    Here is the existing algorithm condensed into easily readable format:
    TRADE_ITEM_THIRD_PARTY_WAR

    Conditions are:

    CvDeal::IsPossibleToTradeItem()?

    // Can't be the same team
    // Can't ask teammates
    // Must be alive
    // Player that would go to war hasn't yet met the 3rd Team
    // Player that wants war not met this team
    // Player that would go to war is already at war with the 3rd Team
    // Can this player actually declare war?
    // Can't ask a player to declare war on their ally

    If it is possible, then put a value on it:

    CvDealAI::GetThirdPartyWarValue

    // How much does this AI like to go to war?
    GetWarProjection(eWithPlayer);
    GetMajorCivOpinion(eOtherPlayer);
    WAR_PROJECTION?
    // Modify based on our War Approach
    // Modify for our feelings towards the player we're would go to war with
    // Modify for our feelings towards the asking player

    All I have done in this mod is to make the cost of the 3rd party war more expensive, and to discourage a higher degree of non-warmonger personalities from considering it.

    Question is whether I change the possibility criterions but return values back to default. By doing that, the AI will be more likely to economically consider the offer, but not if it is impossible for it to consider.

    EDIT:
    Will think up code modification some time but got to go watch MIB3 for now.
    Chow.
     
  16. joncnunn

    joncnunn Senior Java Wizard Moderator

    Joined:
    Mar 17, 2008
    Messages:
    8,621
    Location:
    Missouri
    If the modifications you made are in Beta 13, then to me that's either working fine (or had so little effect I didn't notice) Shared ideology friends still joint DOW someone following another ideology. City state killers get joint DOWed on, etc. (And yes, the AI Zulu pulled off an early city state kill :) , and this was on a different landmass.)

    Basically from the puedscode, what it's missing is at the very top if this is the accept / reject portion of it is (Am I already at war with someone else? If so, then return "NO", bypassing everything else)
     
  17. glider1

    glider1 Deity

    Joined:
    May 29, 2006
    Messages:
    2,834
    Location:
    Where animals hop not run
    Thanks for the suggestion. For the moment I just have made the AI ask a bit less for a third party war than versions V15 onwards, but made sure it won't accept if already at war. I had checks for if the AI is already in late stage planning and implementation, but I'm not confident they work and have retracted them.

    EDIT: There should be a seperate section of code for when the AI accepts a joint war with another AI, but as yet have not found where it is. Pretty sure that when the AI decides to jointly dog-pile another AI, it is not because of third party war deals but because of joint war agreements, or maybe just that it decides it is in its best interest to join in.
     
  18. joncnunn

    joncnunn Senior Java Wizard Moderator

    Joined:
    Mar 17, 2008
    Messages:
    8,621
    Location:
    Missouri
    My Beta 13 game with my tech stagnation mod should now be over in aprox 30 turns, so I'll be ready to start testing the next version soon.

    Edit: Now approx 10 turns
     
  19. glider1

    glider1 Deity

    Joined:
    May 29, 2006
    Messages:
    2,834
    Location:
    Where animals hop not run
    Ok, we have a fast teching tradition player about to try out the new Buffed AI v20 that punishes fast science :lol:

    Enjoy it!

    I removed the free techs in this version so the AI starts on zero tech like us. To be honest, the fact that the AI starts on no-free-techs is more important than restricting its happiness like this mod used to do. With no-free-techs, you can build those wonders if needed.

    Suggest playing one difficulty down from what you used to play on the base game. Emperor is a very good all-round difficulty because it adjusts up if needed anyway. Emperor is very similar to the previous Buffed AI mod versions without the tentative AI.

    If trying to win by science, keep pace to be just behind the main pack in tech. It is not so critical for the other VCs. Slingshoting techs, saving great scientists and timing RAs to syncronise for the endgame all help for the science VC and maybe the others. It can be also useful to encourage AIs to finish off the single-city major civs or just do it yourself.

    This mod for the science VC is very much like long distance foot race. You run with the pack, pick the fast teching leader bunch and just aim to stay in touch with them until the last stretch when you outsprint the lot to cross the finish line first.

    In my first game I tried Babylon for extreme science output but was beaten to a science VC by 20 turns around turn 450. Siam was one civ away from legendary tourism but could not crack the culture of the Iroquois who had become a monster on 26 cities :eek:. So Siam snuck in a science VC instead. The big challenge was keeping the Iroquois off my back.

    Don't be disappointed or frustrated if you loose, the game does play differently with the dynamic difficulty and the fact that the AI is getting all it's normal bonuses except experience and free techs. It takes getting used to.

    I think Joncnunn should consider returning his tech slow down mods to default and trying this mod as is, because the overall tech progress is dictated by the AIs rate of science which is slow enough to be about right for the game speed Firaxis designed for (they did not compensate for all the science shortcuts that humans have found since release). There is no need to rush NC or Oxford trust me. If you push the science throttle too hard, the AI benefits in multiple ways that are not easy to reverse.

    EDIT:
    Download is on the first page again

    PS) In this version the combat adjustments are temporarily unavailable in XML but are still built into the DLL anyway.

    I have tested the revised 3rd party war code. So far I'm liking it but we'll see.

    I here people thinking "hmmm, all I have to do is turtle and I should be able to easily win on emperor..." But the point is that the AIs difficulty level tends to increase itself over time even if you try to turtle, because of the way the automatic difficulty adjuster is coded.



    Spoiler :

    Spoiler alert :eek:
    So, rule of thumb, the difficulty level (per-era-modifier) increases in proportion to the number of your techs known above the average number of techs known for the major AIs in the game. It can drop back down to the chosen difficulty if your tech rate drops again.

    That is the only rule to remember....Other than that the handicaps are the same as the base game except for the AI no-free-techs and AI no-free-experience
     
  20. joncnunn

    joncnunn Senior Java Wizard Moderator

    Joined:
    Mar 17, 2008
    Messages:
    8,621
    Location:
    Missouri
    Were you playing on epic speed or is there a typo in the turn number?
    I don't recall a single Civ V game of mine on normal speed still going on after turn 450 and only recall once (as Venice in my first game as them) taking past turn 400.
     

Share This Page