Happiness Balance Discussion

Current algorithm stops calculating unhappiness from the other needs when the population is reached, so it avoids running some unnecessary code and improves performance.
But it doesn't though? In order to show 0 (max 6) it already has to calculate that 6. How does making the 6 the main piece of information require any more code or computation? Either of my examples would only use numbers which are already present in the current implementation, plus some simple division in the second example.
But since this situation may only happen rarely, and given that G is willing to make the code compute every potential unhappiness, it could be shown as you did in your first example.
13 unhappiness (limited to 4 due to population)
I think previously, if the unhappiness limit was reached before calculating a need, it would skip it as you mentioned, though G has already changed that, I believe. But think about what that meant. You argued that "You know now that 0 illiteracy (max 6) means that you have a severe problem with illiteracy that is not hitting yet because the city is already 100% unhappy." But previously (and I didn't realize this), that information wasn't shown at all, so there was no indication that there was any problem at all with your city's science, even if it was actually the yield with the biggest deficit. That's terrible. You can say it's rare, but it's going to happen in every single game, especially at the beginning, when build order and yields have the biggest impact on the future progression of the game.

Showing zero is better than not showing it at all, but why not just focus the tooltip on which deficits are highest, if that's the information you want? The other numbers are mathematically arbitrary. The unhappiness of a city is always the sum of all the deficits of all the needs, capped at the population. Putting that unhappiness into "distress" slots before "poverty" before "illiteracy" is purely a UI implementation and therefore is not accurately representing the state of the game. You could just as easily do illiteracy first, then culture, etc. and nothing would change functionally, but the player would interpret it completely differently. If the player's interpretation of the same game state changes depending on an arbitrary choice of which yields to calculate first, then there is no "correct" choice. My examples don't use "slots" or any extra layer of obscurity. The illiteracy will always go down when you improve science. If poverty is higher than distress then you know your gold deficit is higher than your food/prod deficit. And it's clear that you have to reduce 13 unhappiness, not 4, to see a difference in your empire's actual happiness.
 
But it doesn't though? In order to show 0 (max 6) it already has to calculate that 6. How does making the 6 the main piece of information require any more code or computation? Either of my examples would only use numbers which are already present in the current implementation, plus some simple division in the second example.
I think previously, if the unhappiness limit was reached before calculating a need, it would skip it as you mentioned, though G has already changed that, I believe. But think about what that meant. You argued that "You know now that 0 illiteracy (max 6) means that you have a severe problem with illiteracy that is not hitting yet because the city is already 100% unhappy." But previously (and I didn't realize this), that information wasn't shown at all, so there was no indication that there was any problem at all with your city's science, even if it was actually the yield with the biggest deficit. That's terrible. You can say it's rare, but it's going to happen in every single game, especially at the beginning, when build order and yields have the biggest impact on the future progression of the game.

Showing zero is better than not showing it at all, but why not just focus the tooltip on which deficits are highest, if that's the information you want? The other numbers are mathematically arbitrary. The unhappiness of a city is always the sum of all the deficits of all the needs, capped at the population. Putting that unhappiness into "distress" slots before "poverty" before "illiteracy" is purely a UI implementation and therefore is not accurately representing the state of the game. You could just as easily do illiteracy first, then culture, etc. and nothing would change functionally, but the player would interpret it completely differently. If the player's interpretation of the same game state changes depending on an arbitrary choice of which yields to calculate first, then there is no "correct" choice. My examples don't use "slots" or any extra layer of obscurity. The illiteracy will always go down when you improve science. If poverty is higher than distress then you know your gold deficit is higher than your food/prod deficit. And it's clear that you have to reduce 13 unhappiness, not 4, to see a difference in your empire's actual happiness.

Wrong on the order part. The order matters, that’s how the game knows which deficiency or issue is going to cause unhappiness first.

G
 
Well. I understand what you say and mostly I would agree with. But the fact is that 100% unhappiness only happens in the early settling phase, all secondary cities cause unhappiness to their population limit and there's nothing to do about it for a while. You don't have the infrastructure, you haven't researched most resources yet, you need some military defense for those pesty barbs and maybe for a greedy neighbor. And once you are ready to address your happiness problems, your cities are already recovering.

As long as performance is not affected, I'm not opposed to the tooltip showing the sum of all potential unhappiness in any case. It's always a good thing to have data, but the usefulness is less than you think it is.
 
Wrong on the order part. The order matters, that’s how the game knows which deficiency or issue is going to cause unhappiness first.

G
That may be what you intended, but I don't think it's true.

Let me pose a question. I have a city with 4 population, and deficits as follows:
  • :c5food:/:c5production: 3/:c5citizen: below need
  • :c5gold: 4/:c5citizen: below need
  • :c5science: 6/:c5citizen: below need
With your implementation, distress causes unhappiness first, then poverty, etc. So the result is as follows:
  • 3 from :c5food:/:c5production: distress (3 max)
  • 1 from :c5gold: poverty (4 max)
  • 0 from :c5science: illiteracy (6 max)
for a total of 4 unhappiness.

But let's say I made a mod to change the calculation, so illiteracy causes unhappiness first:
  • 4 from :c5science: illiteracy (6 max)
  • 0 from :c5gold: poverty (4 max)
  • 0 from :c5food:/:c5production: distress (3 max)
for a total of 4 unhappiness.

You assert that if a different deficiency causes unhappiness first, it will change the way the game is played.

Now let's say I play two versions of this save, one without any changes, and one with my mod. I ignore the fact that these are different systems, and play both games in exactly the same way: no random chance, building the same buildings, etc.

What gameplay choices could I make in both games, that would cause a different result in one game than the other?

I'll give you an example: Let's say I build a building in both games which increases my production so I am only 2 below the need. What is the effect on my happiness? What if I built a science building instead?
 
That may be what you intended, but I don't think it's true.

Let me pose a question. I have a city with 4 population, and deficits as follows:
  • :c5food:/:c5production: 3/:c5citizen: below need
  • :c5gold: 4/:c5citizen: below need
  • :c5science: 6/:c5citizen: below need
With your implementation, distress causes unhappiness first, then poverty, etc. So the result is as follows:
  • 3 from :c5food:/:c5production: distress (3 max)
  • 1 from :c5gold: poverty (4 max)
  • 0 from :c5science: illiteracy (6 max)
for a total of 4 unhappiness.

But let's say I made a mod to change the calculation, so illiteracy causes unhappiness first:
  • 4 from :c5science: illiteracy (6 max)
  • 0 from :c5gold: poverty (4 max)
  • 0 from :c5food:/:c5production: distress (3 max)
for a total of 4 unhappiness.

You assert that if a different deficiency causes unhappiness first, it will change the way the game is played.

Now let's say I play two versions of this save, one without any changes, and one with my mod. I ignore the fact that these are different systems, and play both games in exactly the same way: no random chance, building the same buildings, etc.

What gameplay choices could I make in both games, that would cause a different result in one game than the other?

I'll give you an example: Let's say I build a building in both games which increases my production so I am only 2 below the need. What is the effect on my happiness? What if I built a science building instead?

It’s hard coded in the DLL. You aren’t going to change it via a mod mod. You’re misunderstanding. The UI does not define the mechanic.

G
 
It’s hard coded in the DLL. You aren’t going to change it via a mod mod. You’re misunderstanding. The UI does not define the mechanic.

G
But the mechanic doesn't do anything. Whether it's a mod is unimportant. If the mechanic were actually different but I played identical games the same way, it wouldn't affect anything. Having distress instead of illiteracy doesn't matter. You have the same total unhappiness.
 
But the mechanic doesn't do anything. Whether it's a mod is unimportant. If the mechanic were actually different but I played identical games the same way, it wouldn't affect anything. Having distress instead of illiteracy doesn't matter. You have the same total unhappiness.

Ok? You still have to deal with both. The order does matter, beyond dealing with unhappiness - you have to decide which yield is more important for your empire at the time, and which is likely to be remedied more quickly with the tools on hand. You’re more capable of tackling poverty and distress in the ancient classic period than science or culture. So lean on that. Etc etc.

G
 
Ok? You still have to deal with both. The order does matter, beyond dealing with unhappiness - you have to decide which yield is more important for your empire at the time, and which is likely to be remedied more quickly with the tools on hand. You’re more capable of tackling poverty and distress in the ancient classic period than science or culture. So lean on that. Etc etc.

G
The order you choose to deal with it does matter, obviously, but the order that it's calculated does not. It may be computed in the dll but the result is purely UI.

What you're saying is it's okay to tell the player that there's 0 illiteracy because they should focus on production and food, not because they aren't lacking science. It's lying to the player to force them towards a strategy that you suggest is better/easier (and I disagree, but I'll get to that in a minute).

It's like if the demographic screen only showed your worst value, and hid the rest because "you should focus on the worst one." Or if, when at war, the city screen auto-collapsed the building tab because "you should be building your army with units."

If you think the player should focus on distress before poverty, poverty before illiteracy, etc. that's your prerogative. But the fact is, reducing distress by one does not gain happiness any better than reducing illiteracy by one. And since we've been focused on production when talking about distress, consider the fact that focusing on food to help distress is probably the worst thing you can do for your happiness, because it will grow the unhappiness cap faster without making other yield buildings easier to get the way production or gold do.

And finally, my suggestions still allow the player to prioritize production if they think it will help them get their needs under control fastest. It just doesn't do it by pretending that other yields aren't a problem. The current system heavily implies that if you resolve one distress, you'll lower the city unhappiness by one, when it doesn't. There have been several people in this conversation making that exact mistake of reasoning because it's what the UI implies.
 
The order you choose to deal with it does matter, obviously, but the order that it's calculated does not. It may be computed in the dll but the result is purely UI.

What you're saying is it's okay to tell the player that there's 0 illiteracy because they should focus on production and food, not because they aren't lacking science. It's lying to the player to force them towards a strategy that you suggest is better/easier (and I disagree, but I'll get to that in a minute).

It's like if the demographic screen only showed your worst value, and hid the rest because "you should focus on the worst one." Or if, when at war, the city screen auto-collapsed the building tab because "you should be building your army with units."

If you think the player should focus on distress before poverty, poverty before illiteracy, etc. that's your prerogative. But the fact is, reducing distress by one does not gain happiness any better than reducing illiteracy by one. And since we've been focused on production when talking about distress, consider the fact that focusing on food to help distress is probably the worst thing you can do for your happiness, because it will grow the unhappiness cap faster without making other yield buildings easier to get the way production or gold do.

And finally, my suggestions still allow the player to prioritize production if they think it will help them get their needs under control fastest. It just doesn't do it by pretending that other yields aren't a problem. The current system heavily implies that if you resolve one distress, you'll lower the city unhappiness by one, when it doesn't. There have been several people in this conversation making that exact mistake of reasoning because it's what the UI implies.

To be honest I feel like your arguments have moved so far into the abstraction of the happiness model that I’m not exactly sure what you are trying to apply to the game. The UI tells you current versus max unhappiness from yield deficiencies. What else do you want it to do, exactly?

G
 
To be honest I feel like your arguments have moved so far into the abstraction of the happiness model that I’m not exactly sure what you are trying to apply to the game. The UI tells you current versus max unhappiness from yield deficiencies. What else do you want it to do, exactly?

G
The "current" unhappiness from a yield is a made-up number. It has no meaning except to display an abstraction that the happiness system is using to figure out a city's unhappiness.

The only things that determine a city's unhappiness are its population and the sum of the deficits of all of its yields. That's it. When the total deficits are higher than the population of the city, the unhappiness is capped at the population. It does not matter if you consider the "actual" unhappiness to be coming from distress or illiteracy or wherever. It does not matter that the system computes the "actual" unhappiness by starting with distress and moving down the hierarchy until it hits the population cap. That is purely an implementation, which has no bearing on gameplay whatsoever. It could be implemented in ten different ways, all of which create the same unhappiness from the same yields, but which would show different values for "actual" distress, etc. Those numbers don't matter. Having more "actual" distress doesn't mean you should focus on production. It means the computation happened to look at distress first and ignored everything once it hit the max from the population. Only two values matter: The population and the sum of all deficits. You could correctly calculate the unhappiness of a city and indeed your empire without ever looking at the individual yields, as long as you knew the population and total deficits for each city.

I know you intended for the hierarchy to represent a real life hierarchy of needs, and I don't have any problem with that. What is a problem is that it adds nothing to the game. I don't mean that it isn't interesting, or that it's too small an effect. I mean that it literally does not change the behavior of the game in a way that is distinguishable from not having it, because of how the math works. I'll gladly go over more examples if you're not convinced, but it is true.

The only evidence of the hierarchy during gameplay is the UI, in the form of the happiness tooltip. That means the UI is displaying something completely unrelated to gameplay. The "current" or "actual" numbers are irrelevant to decision making. Further, it leads to mistaken assumptions like this.

So what do I want it to do? I want the tooltip to display values that represent the real state of the game, not side effects of an implementation. I want the tooltip to highlight the things that actually affect unhappiness: the cap due to unhappiness, and the deficit of each yield which added together produce unhappiness up to the population cap. Note that I've described two different ways for it to be displayed, so I don't think I've been unclear about what I want.

I suspect you aren't convinced that the hierarchy doesn't have an effect. I don't know how else to explain it. I can only suggest you show me the difference it makes, with an example. Show me a city with a population and some yields/deficits. Show me the values calculated by the system, and the total unhappiness that results. Then show what the result would be without the hierarchy. Presumably it would be different. Please, I welcome you to show me what I'm missing, here.
 
Last edited:
The "current" unhappiness from a yield is a made-up number. It has no meaning except to display an abstraction that the happiness system is using to figure out a city's unhappiness.

The only things that determine a city's unhappiness are its population and the sum of the deficits of all of its yields. That's it. When the total deficits are higher than the population of the city, the unhappiness is capped at the population. It does not matter if you consider the "actual" unhappiness to be coming from distress or illiteracy or wherever. It does not matter that the system computes the "actual" unhappiness by starting with distress and moving down the hierarchy until it hits the population cap. That is purely an implementation, which has no bearing on gameplay whatsoever. It could be implemented in ten different ways, all of which create the same unhappiness from the same yields, but which would show different values for "actual" distress, etc. Those numbers don't matter. Having more "actual" distress doesn't mean you should focus on production. It means the computation happened to look at distress first and ignored everything once it hit the max from the population. Only two values matter: The population and the sum of all deficits. You could correctly calculate the unhappiness of a city and indeed your empire without ever looking at the individual yields, as long as you knew the population and total deficits for each city.

I know you intended for the hierarchy to represent a real life hierarchy of needs, and I don't have any problem with that. What is a problem is that it adds nothing to the game. I don't mean that it isn't interesting, or that it's too small an effect. I mean that it literally does not change the behavior of the game in a way that is distinguishable from not having it, because of how the math works. I'll gladly go over more examples if you're not convinced, but it is true.

The only evidence of the hierarchy during gameplay is the UI, in the form of the happiness tooltip. That means the UI is displaying something completely unrelated to gameplay. The "current" or "actual" numbers are irrelevant to decision making. Further, it leads to mistaken assumptions like this.

So what do I want it to do? I want the tooltip to display values that represent the real state of the game, not side effects of an implementation. I want the tooltip to highlight the things that actually affect unhappiness: the cap due to unhappiness, and the deficit of each yield which added together produce unhappiness up to the population cap. Note that I've described two different ways for it to be displayed, so I don't think I've been unclear about what I want.

I suspect you aren't convinced that the hierarchy doesn't have an effect. I don't know how else to explain it. I can only suggest you show me the difference it makes, with an example. Show me a city with a population and some yields/deficits. Show me the values calculated by the system, and the total unhappiness that results. Then show what the result would be without the hierarchy. Presumably it would be different. Please, I welcome you to show me what I'm missing, here.

I think there's a misunderstanding: I never said the hierarchy had an effect, other than the fact that it is computationally the model by which the DLL processes the different happiness elements. I've been transparent on that fact with the system since the first time we created this system. I do feel that you're arguing in circles, though - what's the point of your discussion? Have you looked at the latest UI? I'm fairly certain it already achieves your goal.

In reality, the biggest thing the system achieves as-is is that it shows the player the biggest and easiest to reconcile problems first, and the most long-term problems last. Example:

City Size: 10
(2) starving
(2) distress
(2) poverty
(4) illiteracy
(0) boredom (up to 3)

Now this city really sucks. But how do I make it better? Well I could tackle illiteracy first, since it's the biggest issue, but it's also the most long-term issue. So ideally I'd balance food (remove starving), toss an internal trade route into the city (distress) and toss an international route out of the city (poverty). Three steps that will help quite a bit. If you start with illiteracy, you need production to get science, science to get buildings, buildings to get specialists...etc etc. Sure, boredom is going to become an issuer next, but it's like illiteracy: it requires a bit more work to stamp out.

So in this way, by forcing the 'quicker fix' elements to the top of the hierarchy, it informs the player that they should solve these first. Yes, it won't necessarily remove unhappiness, right off the bat, but it does teach the player to build a strong infrastructure before tackling science/culture.

Now, is the system perfect? No, and I've been batting around ideas on how to deal with some of the quirks for some time now.
 
I think that what the hierarchy indirectly does is telling the AI to solve first its distress deficits, then poverty, sfsf. It's a simple way of directing AI into a proven path.
The AI doesn't use the tooltips. If the values make help the AI make decisions, that's one thing. But they still aren't relevant to the player.
I think there's a misunderstanding: I never said the hierarchy had an effect, other than the fact that it is computationally the model by which the DLL processes the different happiness elements. I've been transparent on that fact with the system since the first time we created this system. I do feel that you're arguing in circles, though - what's the point of your discussion? Have you looked at the latest UI? I'm fairly certain it already achieves your goal.

In reality, the biggest thing the system achieves as-is is that it shows the player the biggest and easiest to reconcile problems first, and the most long-term problems last. Example:

City Size: 10
(2) starving
(2) distress
(2) poverty
(4) illiteracy
(0) boredom (up to 3)

Now this city really sucks. But how do I make it better? Well I could tackle illiteracy first, since it's the biggest issue, but it's also the most long-term issue.
The way the UI displays illiteracy in this case is exactly right. It shows that science has the largest deficit, but you're still completely able to prioritize other things. I've never had a problem with the order of the needs. The problem is displaying 0 boredom when there is a deficit of 3. By all means put boredom at the bottom, but why not show the meaningful value, 3, just like this example does for illiteracy? You have 4 illiteracy and 3 boredom to fix. It's still up to you what to prioritize but now it's easy to see the scale of the problem (i.e. show the biggest problems)
So ideally I'd balance food (remove starving), toss an internal trade route into the city (distress) and toss an international route out of the city (poverty). Three steps that will help quite a bit. If you start with illiteracy, you need production to get science, science to get buildings, buildings to get specialists...etc etc. Sure, boredom is going to become an issuer next, but it's like illiteracy: it requires a bit more work to stamp out.
So in this way, by forcing the 'quicker fix' elements to the top of the hierarchy, it informs the player that they should solve these first.
Even if it were true that prioritizing food were always more efficient than production, then gold, etc., that's not a reason to list boredom as 0. Just list it as 3 and keep it on the bottom. Let the player decide what's a priority.

But your assertion that starvation is quicker to fix than distress, poverty, etc. is wrong. Maybe it's generally true that food is a quicker fix, but if your city is lacking science for example, it could be because you've delayed a few science buildings. You might be able to build two science buildings in the time it takes to get one food or production building. Maybe you've already built all the food/production buildings. Or a dozen other factors might just mean there's an easy solution to culture when there's no obvious source of production to get. You can move great works to your city without even taking a turn. You could take a policy or belief that helps the culture or science of that city. Let the player decide what's easiest, and make the information clear enough to do so.

And while, in this situation, resolving the boredom wouldn't improve the unhappiness, it would still be an immediate benefit the moment the city grew. In this scenario, resolving 2 boredom would improve happiness more than resolving 1 starvation or distress, as soon as it grew. But by showing a zero, you're telling the player not to even try to get culture, when it could be the easiest yield to improve, and save them unhappiness in the near future.
Yes, it won't necessarily remove unhappiness, right off the bat, but it does teach the player to build a strong infrastructure before tackling science/culture.
With the shift to using civ-wide medians, it really doesn't. It may be that every city in my empire has great production and food when compared to other yields, but one city is lagging behind in every yield. Even when the infrastructure is the strongest part of that city, it will have starvation and distress, and you're telling the player to ignore science and culture in favor of more infrastructure. Even when culture and science are probably easier to fix (because they've already been neglected).

Worse, you're telling the player to focus on food when there is pending unhappiness waiting to be sprung on every new citizen. I could understand focusing on production, but how on Earth could food be the best solution to unhappiness in a city where your deficits are already limited by population?
Now, is the system perfect? No, and I've been batting around ideas on how to deal with some of the quirks for some time now.
I proposed two alternatives for the tooltip and you haven't commented on either. They are also not that different from what you have.
 
The AI doesn't use the tooltips. If the values make help the AI make decisions, that's one thing. But they still aren't relevant to the player.

The way the UI displays illiteracy in this case is exactly right. It shows that science has the largest deficit, but you're still completely able to prioritize other things. I've never had a problem with the order of the needs. The problem is displaying 0 boredom when there is a deficit of 3. By all means put boredom at the bottom, but why not show the meaningful value, 3, just like this example does for illiteracy? You have 4 illiteracy and 3 boredom to fix. It's still up to you what to prioritize but now it's easy to see the scale of the problem (i.e. show the biggest problems)

Even if it were true that prioritizing food were always more efficient than production, then gold, etc., that's not a reason to list boredom as 0. Just list it as 3 and keep it on the bottom. Let the player decide what's a priority.

But your assertion that starvation is quicker to fix than distress, poverty, etc. is wrong. Maybe it's generally true that food is a quicker fix, but if your city is lacking science for example, it could be because you've delayed a few science buildings. You might be able to build two science buildings in the time it takes to get one food or production building. Maybe you've already built all the food/production buildings. Or a dozen other factors might just mean there's an easy solution to culture when there's no obvious source of production to get. You can move great works to your city without even taking a turn. You could take a policy or belief that helps the culture or science of that city. Let the player decide what's easiest, and make the information clear enough to do so.

And while, in this situation, resolving the boredom wouldn't improve the unhappiness, it would still be an immediate benefit the moment the city grew. In this scenario, resolving 2 boredom would improve happiness more than resolving 1 starvation or distress, as soon as it grew. But by showing a zero, you're telling the player not to even try to get culture, when it could be the easiest yield to improve, and save them unhappiness in the near future.
With the shift to using civ-wide medians, it really doesn't. It may be that every city in my empire has great production and food when compared to other yields, but one city is lagging behind in every yield. Even when the infrastructure is the strongest part of that city, it will have starvation and distress, and you're telling the player to ignore science and culture in favor of more infrastructure. Even when culture and science are probably easier to fix (because they've already been neglected).

Worse, you're telling the player to focus on food when there is pending unhappiness waiting to be sprung on every new citizen. I could understand focusing on production, but how on Earth could food be the best solution to unhappiness in a city where your deficits are already limited by population?
I proposed two alternatives for the tooltip and you haven't commented on either. They are also not that different from what you have.

Have you looked at how the UI is arranged now? It's accurate - it shows '0' for the real amount of unhappiness being applied for median deficiencies if they're not being applied because of citizen cap, but then it highlights, very plainly, that it will go up to x amount if there's citizen space. The current UI is a nice compromise.

G
 
G, I feel like asking something about buildings.

In my game from the January 15 version (I know you don't like examples from old versions but please bear with me) it felt like reducing the modifiers for midgame buildings like Constabularies (from sometimes -40% to -10%) has made numbers tighter than they should be and more susceptible to swings. Does this have any truth to it?
 
Yes. I always play with EUI standard.

Looks fine to me on EUI.

G, I feel like asking something about buildings.

In my game from the January 15 version (I know you don't like examples from old versions but please bear with me) it felt like reducing the modifiers for midgame buildings like Constabularies (from sometimes -40% to -10%) has made numbers tighter than they should be and more susceptible to swings. Does this have any truth to it?

No, because I changed the mechanics behind the function for those buildings. Shouldn't be.

G
 
Back
Top Bottom