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

Happiness Balance Discussion

Discussion in 'General Balance' started by Gazebo, Nov 27, 2018.

  1. tu_79

    tu_79 Warlord

    Joined:
    Feb 11, 2016
    Messages:
    6,359
    Location:
    Malaga (Spain)
    So the goal is to have some unhappiness when something is missing, but preventing unhappiness getting too high. Fine. Should be feasible. That's why you tried with the inverse?

    Wasn't it freezed between newborns?
     
  2. Stalker0

    Stalker0 Baller Magnus

    Joined:
    Dec 31, 2005
    Messages:
    4,955
    So it sounds like the issue is around small yield amounts with large cities.... generally yields that only come from buildings/specialists as opposed to working yields (culture/science predominately).
     
  3. Gazebo

    Gazebo Lord of the Community Patch

    Joined:
    Sep 26, 2010
    Messages:
    17,249
    Gender:
    Male
    Location:
    Little Rock
    It varied. And even though the median yields were static a single specialist change or policy change could swing happiness by a lot. It just wasn’t clear at all. And the AI had a hard time with it.
     
    vyyt and Gothic_Empire like this.
  4. tu_79

    tu_79 Warlord

    Joined:
    Feb 11, 2016
    Messages:
    6,359
    Location:
    Malaga (Spain)
    A problem could be this: Very low values gives the maximum unhappiness, and since it is proportional to pop size, maximum unhappiness equals total population, for each unhappiness. This is why you placed some limits to them, the last being a 50%. A 50% in a 18 pop city is 9 for a single need. That's too high, at least by the numbers we are used to.

    So, instead of making unhappiness directly proportional to total population, what if we use another function, based on population, to limit the unhappiness? We could use the sum of consecutive integers. This is the equivalent of the factorial, but with sums instead of products.
    For example:
    4+ = 1+2+3+4= 10;
    5+ = 1+2+3+4+5 = 15;
    6+ = 1+2+3+4+5+6 = 21;
    A city with a population between 16 and 21 could only get a maximum of 6 unhappiness from each need. Maxunhappy(18) = 6. Then,
    Unhappy = Maxunhappy(CitySize) * (100 - CityEfficiency/MedianEfficiency)

    If this value is still too high, then we could consider square root of the population.
    Maxunhappy = SQRT(CitySize)

    In the case of a 18 pop city, maxunhappy = 4.24, so no more than 4 people can be unhappy from each need. Actually, this one is easier to code:
    Unhappy = SQRT(CitySize) * (100 - CityEfficiency/MedianEfficiency)

    Edit,
    Or even
    Unhappy = SQRT(iLimit) * (100 - CityEfficiency/MedianEfficiency)
     
  5. Enginseer

    Enginseer Salientia of the Community Patch Supporter

    Joined:
    Nov 7, 2012
    Messages:
    3,211
    Gender:
    Male
    Location:
    Somewhere in California
    Im so confused tho, so happiness can be capped at the capital city? So I cannot add 100 happiness to the player(which is given to the capital)?
     
  6. Gazebo

    Gazebo Lord of the Community Patch

    Joined:
    Sep 26, 2010
    Messages:
    17,249
    Gender:
    Male
    Location:
    Little Rock
    If you give happiness to the player, it is divided amongst all cities evenly and the remainder goes to the capital. But yes it’s capped at city size.
     
  7. Gazebo

    Gazebo Lord of the Community Patch

    Joined:
    Sep 26, 2010
    Messages:
    17,249
    Gender:
    Male
    Location:
    Little Rock
    Mathematically it’s fine, but holy crap try to explain that in the UI. That’s the biggest issue. And I think,simple as it is, raw subtraction is the best way to go. Especially since most decisions for dealing with unhappiness are now integral, not percentile.
     
  8. dylansan

    dylansan Chieftain

    Joined:
    Aug 23, 2013
    Messages:
    230
    Gender:
    Male
    Location:
    Massachusetts
    I don't understand why this would happen. I thought the idea was that the yields were compared to the needs proportionally, so 8:c5culture:/10need would give the same unhappiness as 16:c5culture:/20need, rather than the latter giving double unhappiness. I don't see how that would cause big swings with small differences in yields. If anything, I expected it to be more volatile for small cities where +1 yield might be a huge change, but if it were capped by city size it wouldn't matter.
     
  9. crdvis16

    crdvis16 Chieftain

    Joined:
    May 2, 2013
    Messages:
    783
    If I understand correctly the example would be a large city with a low yield. So imagine a pop 12 city that for some reason has very little culture, like 2, such that small changes in the median can jump happiness around a lot.
     
    Gazebo likes this.
  10. Enginseer

    Enginseer Salientia of the Community Patch Supporter

    Joined:
    Nov 7, 2012
    Messages:
    3,211
    Gender:
    Male
    Location:
    Somewhere in California
    This is such a modding limit to Events. If I wanted to distribute happiness among cities, I'd do it, but if I wanted to give raw happiness. I'm unable to because they haven't reached a certain population?
     
  11. Gazebo

    Gazebo Lord of the Community Patch

    Joined:
    Sep 26, 2010
    Messages:
    17,249
    Gender:
    Male
    Location:
    Little Rock
    But what’s the point of such an insane amount of raw happiness as 100 above a city’s need? It won’t do anything mechanically other than turn into GAP.
     
  12. tu_79

    tu_79 Warlord

    Joined:
    Feb 11, 2016
    Messages:
    6,359
    Location:
    Malaga (Spain)
    You know? I feel bad substracting values of the same variable (efficiency) to obtain a complete different variable (unhappy people). This is like saying that one train goes north at 60mph, other goes south at 40 mph, so the height of the driver must be 1,5 ft.
     
  13. Rekk

    Rekk Chieftain

    Joined:
    Dec 9, 2017
    Messages:
    905
    You could also run happiness through a spring equation: The difficulty to increase happiness or unhappiness from zero is directly proportional to the distance from from zero.
     
  14. tu_79

    tu_79 Warlord

    Joined:
    Feb 11, 2016
    Messages:
    6,359
    Location:
    Malaga (Spain)
    Yes, I thought of that, but you have to introduce an arbitrary constant k.
     
  15. dylansan

    dylansan Chieftain

    Joined:
    Aug 23, 2013
    Messages:
    230
    Gender:
    Male
    Location:
    Massachusetts
    Can you give an example of a median and what the happiness is in that case? Maybe I'm not understanding how it was calculated.
     
  16. tu_79

    tu_79 Warlord

    Joined:
    Feb 11, 2016
    Messages:
    6,359
    Location:
    Malaga (Spain)
    A 18 pop city with 2 culture. City efficiency 2/18 = 0.1111. Add some penalties: 0.8. Suppose Median is 3 culture per pop.
    Unhappiness = 50% of 18 pop by (1 - 0.8 / 3) = 6.6

    Suppose median increases slightly to 3.5 culture per pop.
    Unhappiness = 50% of 18 pop by (1 - 0.8 / 3.5) = 6.9

    It's not a huge difference. And it should not change until a new pop is born...
     
  17. Rekk

    Rekk Chieftain

    Joined:
    Dec 9, 2017
    Messages:
    905
    It's not like we aren't already dealing with arbitrary constants in other parts of the game.
     
  18. tu_79

    tu_79 Warlord

    Joined:
    Feb 11, 2016
    Messages:
    6,359
    Location:
    Malaga (Spain)
    True. But Gazebo complained about many artificial modifiers and I was looking at something that could be more simple. Square root is.
    Of course, the spring function is as valid as the others.
     
  19. Gazebo

    Gazebo Lord of the Community Patch

    Joined:
    Sep 26, 2010
    Messages:
    17,249
    Gender:
    Male
    Location:
    Little Rock
    Update:

    Current test with a very warmonger-heavy game (to get a feel for how mass conquest works):

    Spoiler :
    upload_2019-3-14_19-3-44.png


    So far so good.

    Code:
    303, Egypt, TotalHappiness: 88, GoldU: 17, DefenseU: 27, ScienceU: 1, CultureU: 15, War Weariness: 0, Supply: 36, Use: 27
    303, Korea, TotalHappiness: 100, GoldU: 4, DefenseU: 7, ScienceU: 0, CultureU: 1, War Weariness: 0, Supply: 14, Use: 13
    303, Japan, TotalHappiness: 80, GoldU: 32, DefenseU: 35, ScienceU: 2, CultureU: 12, War Weariness: 7, Supply: 42, Use: 22
    303, The Aztecs, TotalHappiness: 100, GoldU: 6, DefenseU: 7, ScienceU: 0, CultureU: 0, War Weariness: 0, Supply: 7, Use: 9
    303, Denmark, TotalHappiness: 71, GoldU: 62, DefenseU: 56, ScienceU: 32, CultureU: 31, War Weariness: 0, Supply: 80, Use: 72
    303, Greece, TotalHappiness: 100, GoldU: 23, DefenseU: 23, ScienceU: 0, CultureU: 21, War Weariness: 0, Supply: 46, Use: 41
    303, The Huns, TotalHappiness: 89, GoldU: 49, DefenseU: 62, ScienceU: 12, CultureU: 18, War Weariness: 3, Supply: 93, Use: 94
    303, Assyria, TotalHappiness: 84, GoldU: 5, DefenseU: 7, ScienceU: 0, CultureU: 2, War Weariness: 0, Supply: 4, Use: 4
    Total Happiness is the % value. So the system can clearly accommodate expansion. Notice that the Danes are currently the only 'unhappy' civ - this is because they took a few cities in quick succession. They're also pumping out Public Works right now to tamp down on new unhappiness caused by empire expansion. The AI knows to only do this when they're truly unhappy - they won't waste hammers otherwise. Also. other such happiness dips have occurred. Assyria, top dog, got crushed by the Huns, who dropped to ~50% during that nail-biter of a war before taking Assyria's capital. The system is also generating very close games, with no discernible runaways or snowball mechanics related to happiness. All good things!

    G
     

    Attached Files:

    vyyt, Kim Dong Un and Gokudo01 like this.
  20. Gothic_Empire

    Gothic_Empire AKA, Ramen Empire

    Joined:
    Aug 5, 2008
    Messages:
    1,488
    Poor Korea :(
     

Share This Page