Please Help Me Make Sense of Happiness

Atheen

Chieftain
Joined
May 9, 2013
Messages
18
Location
Istanbul - Turkey
Hi,

First of my gratitudes for everyone who have been supporting this mod for so long and apologies for my English and terminology as they may be a little rusty. I've been playing CIV5 since release on and off, I've 2300 hour of play time including last 3 years of Vox Populi. I was away from this mod since last summer, tried 06/12 version and my unhappiness problem (particularly distress) became too problematic and uncontrollable for my warmongoring Progress civ.

I read this forum and in-game Civilopedia to get up-to-date with the new happiness mechanics. I understand that it boils down basically to this: every population producing less yield then empire average producess unhappiness ceiled to the city size.

It seems like; when your cities fill up most high yield tiles/specialist slots, every new population is left with low yield tiles which are below empire average yield per pop, resulting an increase in unhappiness. There are also city modifiers and global modifiers such as every new city increases required yield return per pop by 5%, unlocking all tech tree increases it by 100%, and there are also some building like walls / aqueducts giving % reduction to required yield return, and some building which flat out reduces a type of unhappiness like barracks.

As a result of this I'm expected to limit my city number and city size. Growing a city too fast, or expanding too fast will produce out of control unhappiness unless improving land and building infrastructure goes hand in hand with the pace you expand. This is seems like a fun mechanic on paper however I'm not sure if we have means to fight it availabe for us. I'm also struggling with the math behind it and can not figure out the result of my actions on happiness.

I've started a new game and tried to understand the UI to no avail and want your help. Please note that I used the file in this post https://forums.civfanatics.com/threads/new-version-june-12th-6-12.646682/page-3#post-15472034 but I'm not sure if it really affected anything.

This is my game of turn 103. I only have 5 cities with total population of 24

20190624011433_1.jpg


This is the unhappiness tooltip in one of my cities.

20190624011422_1.jpg


The way I understand after reading Civilopedia and inferred from posts about happiness in forums, the math should work like this ignoring round downs/ups;

My total gold income in cities is 51:c5gold:. There is also a 2.5:c5gold: income from a trade route in my other city but I guess it shouldn't have any impact because its not tied to population. If it is, consider the gold income as 53.5.

Because I have 24 population in my empire, the average :c5gold: yield per pop is 51 / 24 = 2.125. The "City Need Modifies" in this city is 11% from tech, 25% from empire size and -5% from something I'm not sure of (maybe difficulty level as walls are not built yet) which adds up to 31%.

2.125 empire average X 1.31 = 2.78:c5gold: per pop. The city has 5 population. So in order to reach empire average yield, it has to produce 5 x 2.78 = 13.92:c5gold:

This is where I'm beginning to get lost. City produces 7:c5gold: but needs 13.9:c5gold: to my understanding. The game UI tells me I'm in deficit of 4.3:c5gold: which results in 3 unhappiness.

  • What is the relation between these numbers?
  • Does it have anything to do with this figure from patch notes?
    Base divisor for yields now 25 (Was 100) - makes yield deficits more sensitive in cities
    Please note that I've reverted this to 100 in my game files because above mentioned post said it would help but not sure if it took any effect...
  • Why does this deficit result in 3 unhappines? Why not 2 or 4 or 5?
  • modifier in my game files is
    SELECT 'BALANCE_HAPPINESS_TECH_BASE_MODIFIER', '50'
    How does this modifier gives 11% increase on city modifier. I've researched 14 techs yet, including Agriculture (starting tech)
  • Am I an idiot and the real math is completely different.
Sincere thanks, this community is great, this mod is great :clap:
 
Last edited:
If no one is able to help or it's too complicated to explain it, can someone at least lead to an old post explaining the math? I searched some old threads but couldn't find anything. Is there a discussion thread dating to the introduction of this new happiness mechanic perhaps...

Thanks...
 
Sorry (you're post is quite intimidating by its length)
I think the -5% on yields you have everywhere come from a social policy (one of Progress has this effect).

I'm quite out of date on the math, and tried to look at the files, and found mostly that:

Code:
BaseValue = 25 \\ or 100 is you changed it
Mod = ... \\ 31 for your city
GlobalAverage = ... \\ Mostly the median of that yield worldwide, but exactly that.
ThresholdPerPop = GlobalAverage*(100+Mod)/100
Unhappiness = (ThresholdPerPop - CityYieldPerPop)*100/BaseValue

Here, the deficit is 4.3 so the threshold must be 11.3 :c5gold: if the tooltip is not wrong, so 2.3 :c5gold: per citizens, which would mean that the global average of gold is 1.7 :c5gold:.
It gives an unhappiness of (4.3/5*100)/25 which is 3.44, rounded down to 3. (then reduce to 2 by a building)

It seems your modification of the 25 by 100 did not affect your game, maybe you didn't modify all the occurrences of it (one per yield)? Or maybe you didn't clear the cache?

Edit: corrected the math
 
Last edited:
It's nice to understand how the numbers happen to be, but it's more interesting to know what to do about it.

See that worker in rostov that is working a 1food 1 hammer tile? Your city is already at max unhappiness, you don't want it to grow for a while. So, better to put this worker on a hill that will give you 2 hammers. Distress won't change, but you'll build things faster and prevent the city from growing while it's unhappy. Even better, purchase that sheep tile. You can improve it easily and it'll be much better than most available tiles.

Another option is to build a market. This building has a merchant slot. They are not great, but will provide some gold and will help you to control growth since specialists consume more food.
 
Hum, rereading the code, it's not clear if the global average is worldwide or playerwide.
Has anybody followed the recent changes to know which one it is?

[Note that whatever which of the two is the good one, it most likely a median, not an arithmetic average]
 
This is where I'm beginning to get lost. City produces 7:c5gold: but needs 13.9:c5gold: to my understanding. The game UI tells me I'm in deficit of 4.3:c5gold: which results in 3 unhappiness.

  • What is the relation between these numbers?
  • Does it have anything to do with this figure from patch notes? Please note that I've reverted this to 100 in my game files because above mentioned post said it would help but not sure if it took any effect...
  • Why does this deficit result in 3 unhappines? Why not 2 or 4 or 5?
  • modifier in my game files is How does this modifier gives 11% increase on city modifier. I've researched 14 techs yet, including Agriculture (starting tech)
  • Am I an idiot and the real math is completely different.
Sincere thanks, this community is great, this mod is great :clap:

Don't bother trying to do the math yourself, the system is designed to be handled purely from the tooltip info and not having to do a bunch of math yourself. I have absolutely no clue how any of the math works but I manage happiness just fine.

Essentially, you have a total gold deficit of 4.3 resulting in 3 unhappiness. If you increase your gold by 0.56, you'll reduce the unhappiness from gold by 1, leaving you with 2 unhappiness. All you really need to do to manage unhappiness is pay attention to your current unhappiness sources and build things to address them while also monitoring what will happen when you grow to make sure you don't make the situation worse.
 
Thanks for the insight. To be fair I'm still trying to adapt to this new system. In some older iteration of this mod, you would always try to grow your cities, even if they produce unhappiness in short term they would eventually overcome this by producing / building more stuff in the long term. But, in this system it seems like once a city is unhappy its much harder to solve it without using "Avoid Growth" and new specialist system doesn't make it easy at all.

I wanted to have a grasp of its math because I've observed some weird things for example a city has 4:c5unhappy: from distress and needs 2 :c5production:/:c5food: to reduce it by 1. I purchased a Monastery (Fealty policy) which gives +3:c5food: and expected distress to go down by one. To my surprise, it remained unchanged but 4:c5unhappy: from poverty went down by 1 to 3:c5unhappy: even though monastery shouldn't affect :c5gold:. My guess is the city auto-assigned a now available specialist as a merchant which negated the :c5food: gain from monastery and reduced poverty because of merchant yield, but I was too lazy to reload and compare before and after. This system needs a lot more micro-management but I guess I need to adapt it. However, these rules with specialists are really confusing and hard to manage.

It seems your modification of the 25 by 100 did not affect your game, maybe you didn't modify all the occurrences of it (one per yield)? Or maybe you didn't clear the cache?

How does clearing the cache works? If I change any game file in the future how should I clear the cache?

Thanks..
 
The median used is the global median, not the player one.

The median is taken by looking at all the cities in the world, taking the yield per population in a city for a given need in all cities, and finding the median yield per pop value for that given yield (eg. Gold for Poverty). Then modifiers apply and the deficit between the modified median and your city's yield per pop creates unhappiness.

I've never actually looked into or understood the happiness code though. This is just what I have gathered from discussions.
 
I wanted to have a grasp of its math because I've observed some weird things for example a city has 4:c5unhappy: from distress and needs 2 :c5production:/:c5food: to reduce it by 1. I purchased a Monastery (Fealty policy) which gives +3:c5food: and expected distress to go down by one. To my surprise, it remained unchanged but 4:c5unhappy: from poverty went down by 1 to 3:c5unhappy: even though monastery shouldn't affect :c5gold:. My guess is the city auto-assigned a now available specialist as a merchant which negated the :c5food: gain from monastery and reduced poverty because of merchant yield, but I was too lazy to reload and compare before and after. This system needs a lot more micro-management but I guess I need to adapt it. However, these rules with specialists are really confusing and hard to manage.

That hasn't got anything to do with math, but rather the fact that a city can only ever be 100% unhappy. So in the picture you posted originally you technically have enough deficits to have 6 unhappiness, but you aren't getting the 1 unhappiness from boredom because your 5 citizens are already all unhappy from distress and poverty. So you'd have to reduce the deficits by 2 before you saw a change in happiness.
 
How does clearing the cache works? If I change any game file in the future how should I clear the cache?

Thanks..

Just delete the folder "C:\Users\Username\Documents\My Games\Sid Meier's Civilization 5\cache".
If you're using the mod from the auto-installer, just changing the values and clearing the cache should be enough (note: if you're loading a save, you might need to wait for the city to grow for the values to update).

[If you're using a DLC-modpack instead of the auto-installer, you also need to modify the appropriate file in the override folder (might be a little tricky to find)]
 
I wanted to have a grasp of its math because I've observed some weird things for example a city has 4:c5unhappy: from distress and needs 2 :c5production:/:c5food: to reduce it by 1. I purchased a Monastery (Fealty policy) which gives +3:c5food: and expected distress to go down by one. To my surprise, it remained unchanged but 4:c5unhappy: from poverty went down by 1 to 3:c5unhappy: even though monastery shouldn't affect :c5gold:. My guess is the city auto-assigned a now available specialist as a merchant which negated the :c5food: gain from monastery and reduced poverty because of merchant yield, but I was too lazy to reload and compare before and after.
Distress works off of gross food/production not net. Consumption doesn't affect distress. If it auto-assigned a specialist off of a food tile, then it could have the effect you're seeing.

Another couple of things. Needs are based on a modified global median based on the passive yields of all civilizatioms. You're never going to figure out what this is directly, unless you work backwards from your own deficit (which makes the number useless for comparison). As such the % modifiers just give an indication of how your needs are increasing with technology/empire size.

However, you do know the total deficit, your city's population and your city's passive yields. With that, if you want you can calculate your total deficit per population. You get one :c5unhappy: per 0.25 (or 1 if you've successfully modified the code) deficit yields per population.
 
Last edited:
Back
Top Bottom