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

How Difficulty Bonuses work for AI

Discussion in 'General Balance' started by Gazebo, Nov 29, 2017.

  1. Txurce

    Txurce Deity

    Joined:
    Jan 4, 2002
    Messages:
    8,263
    Location:
    Venice, California
    Can't beat metaphors for flexibility.
     
  2. Infixo

    Infixo Deity

    Joined:
    Jan 9, 2016
    Messages:
    3,592
    Gender:
    Male
    Location:
    Warsaw
    Semantics aside, these are outside of any "sorts of" rules.
    Code:
    BUILDING_SOLAR_PLANT   YIELD_PRODUCTION   50
    BUILDING_NUCLEAR_PLANT   YIELD_PRODUCTION   50
    
    BUILDING_TRAINSTATION   YIELD_PRODUCTION   25
    BUILDING_SEAPORT   YIELD_PRODUCTION   25
    BUILDING_SPACESHIP_FACTORY   YIELD_SCIENCE   25
    
    CORPORATION_TRADER_SIDS   YIELD_GOLD   50
    CORPORATION_FIRAXITE_MATERIALS   YIELD_SCIENCE   100
    
    Like I said somewhere else - no single building, policy, etc. is problematic. They just stack up.
    These above are not even gold-related in most part.
     
  3. Deadstarre

    Deadstarre Expert

    Joined:
    Nov 1, 2015
    Messages:
    960
    Location:
    New York
    trainstation is more like %35 since it has +25 and +10, its pretty beastly and boy does it spur the hunt for coal.
     
    IcyAngel likes this.
  4. Gazebo

    Gazebo Lord of the Community Patch Supporter

    Joined:
    Sep 26, 2010
    Messages:
    17,848
    Gender:
    Male
    Location:
    Little Rock
    Those are all so late that they have to be high to be worth the investment, otherwise they never pay off.
     
  5. Infixo

    Infixo Deity

    Joined:
    Jan 9, 2016
    Messages:
    3,592
    Gender:
    Male
    Location:
    Warsaw
  6. Gazebo

    Gazebo Lord of the Community Patch Supporter

    Joined:
    Sep 26, 2010
    Messages:
    17,848
    Gender:
    Male
    Location:
    Little Rock
    I'm not at my PC so I can't run the numbers immediately but someone like @CrazyG may be able to - this has all been discussed before.

    G
     
  7. Deadstarre

    Deadstarre Expert

    Joined:
    Nov 1, 2015
    Messages:
    960
    Location:
    New York
    well the later eras pass more quickly than the early ones (shorter length of turn times), but on medium or lower difficulties i'm pretty sure Industrial era would appear much more mid game than late game
     
  8. Infixo

    Infixo Deity

    Joined:
    Jan 9, 2016
    Messages:
    3,592
    Gender:
    Male
    Location:
    Warsaw
  9. tu_79

    tu_79 Deity

    Joined:
    Feb 11, 2016
    Messages:
    6,938
    Location:
    Malaga (Spain)
    Information is so ephimeral sometimes, that I understand people not counting this era.
     
  10. Moi Magnus

    Moi Magnus Emperor

    Joined:
    Mar 1, 2015
    Messages:
    1,867
    What do you think about indexing Barbarians spawn rate to the difficulty level ?
    In Chieftain-Prince, the AI is quite bad at clearing barbarians, making them very dangerous to the player. While in Deity, unless you are isolated, they are mostly irrelevant due to being hunted by the AI.

    (Of course, if it is not possible in the code, ...)
     
    vyyt likes this.
  11. Gidoza

    Gidoza Emperor

    Joined:
    Jul 26, 2013
    Messages:
    1,160
  12. Moi Magnus

    Moi Magnus Emperor

    Joined:
    Mar 1, 2015
    Messages:
    1,867
  13. ElliotS

    ElliotS Warmonger

    Joined:
    Jun 13, 2013
    Messages:
    2,704
    Gender:
    Male
    Location:
    Chicago
    Speaking of: @Gazebo can you please give us the most up to date formula for Handicap bonuses? That one is a bit old. Thanks!
     
    LukaSlovenia29 likes this.
  14. Gazebo

    Gazebo Lord of the Community Patch Supporter

    Joined:
    Sep 26, 2010
    Messages:
    17,848
    Gender:
    Male
    Location:
    Little Rock
    Code:
    int CvPlayer::DoDifficultyBonus(HistoricEventTypes eHistoricEvent)
    {
        if (eHistoricEvent == HISTORIC_EVENT_DIG || eHistoricEvent == HISTORIC_EVENT_TRADE_CS)
            return 0;
    
        int iEra = GetCurrentEra();
        if(iEra <= 0)
        {
            iEra = 1;
        }
        int iHandicapBase = 0;
        int iHandicapA = 0;
        int iHandicapB = 0;
        int iHandicapC = 0;
        int iYieldHandicap = 0;
        CvHandicapInfo* pHandicapInfo = GC.getHandicapInfo(GC.getGame().getHandicapType());
        if(pHandicapInfo)
        {
            iHandicapBase = pHandicapInfo->getAIDifficultyBonusBase();
            iHandicapA = pHandicapInfo->getAIDifficultyBonusEarly();
            iHandicapB = pHandicapInfo->getAIDifficultyBonusMid();
            iHandicapC = pHandicapInfo->getAIDifficultyBonusLate();
            iYieldHandicap = iHandicapBase * (iHandicapA * iEra * iEra + iHandicapB * iEra + iHandicapC) / 100;
        }
        if (iYieldHandicap > 0)
        { 
            if (eHistoricEvent == HISTORIC_EVENT_ERA)
                iYieldHandicap *= 2;
            else if (eHistoricEvent == HISTORIC_EVENT_GP)
                iYieldHandicap /= 3;
            else if (eHistoricEvent != NO_HISTORIC_EVENT_TYPE)
                iYieldHandicap /= 2;
    
            bool IncludeCities = true;
            if (eHistoricEvent == HISTORIC_EVENT_GP ||
                eHistoricEvent == HISTORIC_EVENT_WONDER ||
                eHistoricEvent == HISTORIC_EVENT_TRADE_LAND ||
                eHistoricEvent == HISTORIC_EVENT_TRADE_SEA)
            {
                IncludeCities = false;
            }
    
            if (IncludeCities)
            {
                int iLoop;
                CvCity* pLoopCity;
                for (pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))
                {
                    if (pLoopCity != NULL)
                    {
                        pLoopCity->changeFood(iYieldHandicap);
                        pLoopCity->changeProduction(iYieldHandicap);
                    }
                }
            }
    
            GetTreasury()->ChangeGold(iYieldHandicap);
            ChangeGoldenAgeProgressMeter(iYieldHandicap);
            changeJONSCulture(iYieldHandicap / 2);
          
            TechTypes eCurrentTech = GetPlayerTechs()->GetCurrentResearch();
            if(eCurrentTech == NO_TECH)
            {
                changeOverflowResearch(iYieldHandicap);
            }
            else
            {
                GET_TEAM(getTeam()).GetTeamTechs()->ChangeResearchProgress(eCurrentTech, iYieldHandicap, GetID());
            } 
        }
        return iYieldHandicap;
    }
     
    ElliotS and LukaSlovenia29 like this.
  15. ElliotS

    ElliotS Warmonger

    Joined:
    Jun 13, 2013
    Messages:
    2,704
    Gender:
    Male
    Location:
    Chicago
    Thanks! Updated. :)
     
  16. Stalker0

    Stalker0 Baller Magnus

    Joined:
    Dec 31, 2005
    Messages:
    6,249
    I thought A was the early handicap and C the late one, but its A that gets the most bonus with era scaling...so I'm confused.
     
  17. ElliotS

    ElliotS Warmonger

    Joined:
    Jun 13, 2013
    Messages:
    2,704
    Gender:
    Male
    Location:
    Chicago
    A is late, and C is early. I can see why the order would confuse you a bit though.
     
  18. Gazebo

    Gazebo Lord of the Community Patch Supporter

    Joined:
    Sep 26, 2010
    Messages:
    17,848
    Gender:
    Male
    Location:
    Little Rock
    Yeah, they are just named incorrectly in that function.

    G
     
  19. Gidoza

    Gidoza Emperor

    Joined:
    Jul 26, 2013
    Messages:
    1,160
    Yes that helps, thank you!

    But you could interpret what the phrase means, "The difficulty in the Community Patch is unchanged, but the rest of Vox Populi changes difficulty greatly, as described below." This isn't a very clear statement to me. G often says that such-and-such a difficulty in Vanilla is like such-and-such a different difficulty in Vox Populi, so a more clear statement of what is going on would be nice.
     
  20. Moi Magnus

    Moi Magnus Emperor

    Joined:
    Mar 1, 2015
    Messages:
    1,867
    You are free to edit it to make things clearer.
     

Share This Page