Freeciv
Advertisement
Happiness page

Due to empire and city size, basically one citizen is angry and the rest are unhappy, but luxury taxing (30%) and other effects keep the city at peace.

City "Happiness" is a special term in Freeciv that represents more than just the mood of a city's citizens. It represents how they feel, their morale, culture, and communal unity. Happiness may even affect the productivity of their work. Each citizen has four potential happiness states: content, happy, unhappy and angry. Based on the totals of these, there are three potential mood/happiness states for the entire city: celebrating, peace, disorder (lawless*).

Only citizens that are working tiles change their mood due to happiness effects. Specialists are always content. You can examine the happiness of citizens in a city in the top line of citizen icons in the main tab of the city dialog. A more thorough inspection is available inside the tab labeled "Happiness" or "Happy."

This article gives technical details on city happiness. For a general ruleset description dedicated to happiness in cities, please consult the article for the specific ruleset: Classic, Multiplayer, Multiplayer II, Multiplayer II Caravel.

*In some implementations, "disorder" represents a threatened upcoming state, whereas "lawless" represents the arrival of that state.

Basic concepts[]

Citizens who work tiles have four levels of happiness: happy, content, unhappy and angry.

Unhappy and angry citizens still work, but if they outnumber happy citizens in their city (angry ones counted twice!), the city is thrown into disorder. Cities in disorder generate no surplus food, no gold, and no production (shields). However, production-based pollution will still be active. Cities in disorder can overthrow some governments.

If there are no unhappy or angry citizens and at least half of the total population are happy workers, the city will enter a celebration state on the next turn change. In most rulesets, each government has different bonuses that come to celebrating cities. Happiness has some other effects: it decreases the chance of civil war, and if one incites a city, it costs more to incite a happy worker than an angry one.

Causation Layers[]

In the city Happiness tab, there are six layered levels of "feeling": cities, luxury, buildings, nationality, units, and wonders (final). These levels are separate computation layers, allowing you to see 6 layers of inputs affecting the final state of happiness in the city. As far as the game is concerned, only the last level of happiness matters.

The names of the layers only roughly correspond to the inputs and computations that go into them. (Simple layer names were chosen for simplicity's sake.) For example, some buildings that "make happy" actually contribute to the Wonders Layer, whereas some wonders that "make content" contribute to the Buildings Layer. Police Station may have martial law effects in some rulesets. And so on.

Notes:

  • Most of the code related to city happiness resides in server/city.c.
  • Ruleset code related to city happiness is predominantly found in effects.ruleset
  • City size for Celebration is ruleset regulated by parameters.celebrate_size_limit
  • It was planned to make disorder effects for a city adjustable by the ruleset.
  • Angry citizens may be turned off by parameters.angry_citizens in game.ruleset, making citizens who would be angry only unhappy.
  • Incite cost roughly tracks to with sums of corresponding citizens by all the nation.

Basic feeling[]

The first level of happiness in the happy tab can be called "Basic feeling", or "Cities feeling"—since this basic level is caused by numbers related to city population and number of cities in your empire.

In this level, there are three effects and two numbers that matter.

  • "City_Unhappy_Size" - how many citizens in a city are naturally content before additional citizens from population growth are unhappy. (Prior to empire size effects described below.)
  • "Empire_Size_Base" - up to this number of cities, City_Unhappy_Size is unchanged. After this number of cities, City_Unhappy_Size is reduced by 1.
  • "Empire_Size_Step" - the number of additional cities beyond Empire_Size_Base that progressively reduce City_Unhappy_Size by 1. For example, if this number is 10, City_Unhappy_Size will be reduced 2 at Empire_Size_Base+10, reduced 3 at Empire_Size_Base+20, reduced 4 at Empire_Size_Base+30, and so on.

Computing these three things above gives us a number x. If it is positive, then the first x citizens in a city will be content; this value x is capped by city size and includes specialists (i.e.: if x=2, city size is 4, and 3 citizens are specialists, then 2 specialists are content because of an effect, one because of being a specialist, and the worker is not content). If x is negative, all citizens will be unhappy and the surplus negativity will begin to make them angry (if the ruleset enables angry citizens.) If there are any citizens working tiles, they are unhappy. No working citizen can be happy at this level.

Luxury feeling[]

You can get luxuries from entertainers, trade taxes, wonders, and "Output_*" type effects often applied to city center tile, etc. The surplus of city luxuries is used to lift citizens to a higher happiness level. To lift one citizen costs civstyle.happy_cost from game.ruleset. Luxury is applied to citizens in the exact sequence below:

  • firstly, angry→unhappy;
  • then, content→happy;
  • then, unhappy→happy (for double cost);
  • if remaining luxury isn't enough to finish unhappy→happy, the last unhappy citizen may become content.

This means you can't eliminate unhappiness with luxuries without first making all content citizens happy.

Notes:

  • (Entertainers or other luxury-producing specialists use "Specialist_Output" effect with "Output_Type", "Luxury", "Local" requirement) These are in effects.ruleset and specialists are defined in cities.ruleset

Buildings feeling[]

This level is modified from the previous one by the city-specific "Make_Content" effect, mostly caused by the city's buildings or player's wonders. The total sum of "Make_Content" effects are spent one by one firstly on angry→unnhappy, then on unhappy→content.

Note that the effect "Happiness_To_Gold" does not cancel this effect.

Nationalities feeling[]

If there are citizens in the city that are of a nation you are currently at war with, they don't like it. You get one penalty unit for "Enemy_Citizen_Unhappy_Pct" city-specific effect value percentage of such citizens (rounding down). The penalty is applied in this order:

  • firstly, content→unhappy;
  • then, happy→unhappy (for 2 units);
  • the last affected happy one may become content.

This level does not increase angry citizens.

Units feeling[]

If the government allows martial law, then first, city martial law is calculated. Up to effect "Martial_Law_Max" military units deployed at the city center potentially make "Martial_Law_Each" cirizens content per each military unit present. (Military units are ones without the "NonMil" type flag.) This value is firstly spent on angry→unhappy, then on unhappy→content, whatever remains is lost. The units counted must be owned by the cityowner.

Then, each aggressively deployed unit and "FieldUnit" unit is tallied for its happiness upkeep as defined in the unit type and effects usually tied to the current government. This total is potentially then reduced by any "Make_Content_Mil_Per" effect (down to 0), though use of this effect is rare in most rulesets. Unhappiness is then summed up and from the sum is subtracted any "Make_Content_Mil" effect (result down to 0). This effect is applied the same way as in the same conversions for Nationalities feeling:

  • firstly, content→unhappy;
  • then, happy→unhappy (for 2);
  • the last affected happy one may become content.

It does not produce angry units (but in further game versions maybe...).

Final feeling (or Wonders Feeling)[]

"Wonders feeling" is sometimes called Final feeling, since it is the final calculated level. In this final level, mostly the effects from Wonders on happiness are calculated.

At this final stage the effects are mostly provided by wonders, in this order:

  • "Make_Happy" - applied first on content→happy, then (for 2) unhappy→happy. Remainder is kept.
  • "No_Unhappy" - if positive, remaining unhappy and angry citizens all become content;
  • "Force_Content" - the value is added to the remnant of the "Make_Happy" effect, and the result is spent on angry→unhappy, then unhappy→content.

After calculations for Final feeling, the final result is represented to generate the actual real mood of the city's happiness, in the game. This means: Final feeling is used to calculate if the city will have the state of Celebrating, Peace, or Disorder.

Notes:

  • If there are still angry citizens at the beginning of this stage, they will get content at best.
Advertisement