Table of Contents

Population and Morale

There are three classes of colonists in OP2:

Morale is a “colony happiness” value that is computed from various colony conditions, as well as events that occur during gameplay. This value ranges from 0-99, but this range is segmented into various morale levels which apply various modifiers to other mechanics in the game:

Morale Level Min Morale Research Modifier Production Modifier Food Modifier Fertility Modifier Death Modifier
Excellent 90 15 -25 20 35 620
Good 70 8 -10 8 46 500
Fair 45 0 0 0 64 390
Poor 25 -8 10 -5 82 280
Terrible 0 -15 20 -10 107 180

These levels are defined in morale.txt. The game also implements a power modifier that can give a bonus or penalty to power production, but this is set to 0 for all morale levels. (The table in morale.txt also defines a “defect rate” which is 0 for all levels except Poor (5) and Terrible (10), but this is unused by the game as far as anyone is aware).

In “morale steady” games this is typically forced to Good, but the mission designer can force morale to any of these levels.

Strategy

Morale Model

There are two kinds of morale, Base Conditions, and Events. These are handled separately. Every 256 ticks, these values are computed and used to determine a player's overall morale. This calculation is only performed for human players. For AI players, the morale level is forced to Fair.

Base conditions are derived from colony conditions such as unemployed workers, disabled buildings, food production, etc. Events are temporary morale adjustments that happen which are computed into a single value that decays over time such as kid births, disasters, structures destroyed, etc.

While many of the values in morale.txt are stored as a percentage out of 100, internally the game scales these values to be a fraction out of 256. The calculations described below use the game's scaled value as such, e.g.:

Internal Value = ((Percent * 256) + 50) / 100

The game also stores various ratios described below in terms of hundredths of a percent (i.e. 100% = 10000) to avoid floating point rounding errors in calculation. These get scaled accordingly when shown on the UI.

Event Morale Decay

First, event morale decays according to the following formulas:

Event Morale = (Event Morale * EVENT_DEC_RATE + (255 if Event Morale is negative)) / 256

Adding 255 in the case that event morale is negative ensures that it will get back to 0 given enough time. EVENTDECRATE is a value from morale.txt used to adjust the decay rate.

Base Conditions

Next, base conditions are calculated, determining how current colony conditions affect morale. This gives a base number from which to start morale calculations from. In the absence of events, this will become your current morale. This value can swing wildly if base conditions change significantly during the period between successive morale updates.

Residence Demand

First, if residence capacity is nonzero, residence demand is computed using the following formula:

Residence Demand = ((Kids + Workers + Scientists)) * 100 / Total Residence Capacity

Total residence capacity is the sum of Production_Capacity (as defined in building.txt and upgradeable by techs) for all residences the player has (by default, Residence = 25, Advanced Residence = 50, Reinforced Residence = 40. Residence can be upgraded to 75 via the Environmental Psychology tech).

As mentioned before, this (and all ratios in this section) is essentially a percentage stored in terms of hundredths of a percent, to avoid rounding errors (in other words, 100% = 10000).

If residence capacity is 0, this gets set to 100%.

Food Supply

A food supply level is calculated based on the following logic:

Disabled Building Ratio

This ratio is computed based on:

Disabled Building Ratio = (Num Buildings - Num Idle Buildings - Num Active Buildings) * 100 / Num Buildings

In the cases of no buildings (or all buildings idle), or all buildings disabled, the ratio gets set to 0 or 100% respectively.

Rec Center / Forum Demand

This defaults to 100% if rec center and forum capacity are both 0, otherwise:

Rec and Forum Demand = (Total Population * 100) / (Total Forum Capacity + Total Rec Center Capacity)

Operational Building Checks

The game records whether there are any active Nursery, University, and GORF (storing this as a boolean separately for each building type).

DIRT Average Damage Prevention

TODO: This part needs some more analysis to determine how the game figures out DIRT damage prevention

Unoccupied Colonists

Unless the population solely consists of Kids (in which case this value defaults to 0), unoccupied colonist percentage is determined:

Unoccupied Colonist Ratio = ((Available Workers + Available Scientists) * 100) / (Workers + Scientists)

Scientists as Workers

This is set to 0 if the player has no scientists, otherwise:

Scientists as Workers Ratio = ((Scientists As Workers * 100) / Scientists

Overcrowding Multiplier

An overcrowding multiplier is determined from residence demand, based on values in morale.txt. Note that these stack as follows:

Residence Demand Modifier Total
⇐ 100% (None) 2 2
⇐ 133% (Low) -1 -1
⇐ 166% (Med) -1 -2
⇐ 200% (High) -2 -4
> 200% (Max) -2 -6

Food Modifier

This also comes from morale.txt and is based on the food supply level computed earlier, stacking as follows:

Food Supply Modifier Total
Surplus 2 2
Deficit (Big Supply) 1 3
Deficit -2 0
Starving -2 0

Disabled Building Modifier

Also from morale.txt, this corresponds to the disabled building ratio, stacking as follows:

Ratio Modifier Total
0% (Low) 2 2
<33% (Med) -1 1
<66% (High) -1 0
66%+ (Max) -2 -2
10000 (default) Same as Low

Rec/Forum Demand Modifier

This stacks similarly to the previous modifiers, defined as 1 in morale.txt:

Demand Modifier Total
⇐ 100% (Low) 1 1
⇐ 150% (Med) 1 2
⇐ 200% (High) 1 3
> 200% (Max) 1 3

Med Center Demand Modifier

Demand Modifier Total
⇐ 100% (Low) 1 1
⇐ 150% (Med) 1 2
⇐ 200% (High) 1 3
> 200% (Max) 1 3
10000 (default) 0

Operational Modifiers

Scientists as Workers % Modifier Total
>= 5% (Low) -1 -1
>= 20% (Med) -1 -2
>= 40% (High) -2 -4
>= 65% (Max) -3 -7

Population Model

The colony population is updated every 32nd processing tick (256 ticks) for each human player. AI players are forced to 4096 workers, 4096 scientists, and 256 kids.

The following discussion makes use of MFERTRATE and MDIERATE from morale.txt. MFERTRATE determines the rate at which new kids are born. The values are unintuitive: a lower value means a higher birth rate. MDIERATE determines the rate at which people (kids, workers, and scientists) die. As uninituitively as before, a HIGHER value means a LOWER death rate.

Medical Center Capacity

In addition, the “total med center capacity” below is the sum of the Production_Capacity (as defined in building.txt and upgraded by techs) of all active Medical Centers owned by the player. This defaults to 50 for the base Medical Center and 75 with Automated Diagnostic Examinations.

New Kids and Workers

First, new workers are trained from kids, if there are any to train, and the player has an active University (having more than 1 university has no effect here), the worker count is increased (and kid count decreased) based on the following formula:

Trained Workers = (((min(160, Kids + Workers + Scientists) / 40) * 3 + 36) * 4) / (Remainder + Kids)

The remainder from this division is stored and used the next time the population is updated in this formula (starting at 0 when the game starts). This allows for fractional worker growth over multiple updates.

Next, the number of new kids is calculated based on the birth rate, if the player has an active Nursery (as before, having more than 1 nursery has no effect) and the total number of workers and scientists is less than the number of kid (i.e. kids are capped at 50% of total population), based on the following formula:

Kids Born = (Scientists / 4 + Workers / 2 + Remainder) / M_FERT_RATE

As before, the remainder is stored and used in the next update to allow for fractional kid growth over time. MFERTRATE is a value defined in morale.txt for each morale level.

Kid, Worker, and Scientist Deaths

Kid deaths are computed next, if the number of kids is greater than 0, according to the following formula:

Kid Deaths = (Kids + Remainder) / (Nurseries * 40 + M_DIE_RATE / 2 + Total Med Center Capacity)

The remainder is stored for use in the next update, and total med center capacity is a previously computed value for each player. In other words, Nurseries are assumed to have a capacity of 40 (note that this becomes fairly pointless once Med Centers are available as they lower death rate for all colonists and have a higher capacity, for the same upkeep in workers, scientists, and power). MDIERATE is a value from morale.txt based on the player's current morale level.

Worker and Scientist deaths (assuming there are any) are separately computed similarly using the formula below:

Worker or Scientist Deaths = (Workers or Scientists + Remainder) / (Total Med Center Capacity + M_DIE_RATE)

As before, the remainder is stored and used in the next update (separately for scientists and workers).

Scientist training is not handled here, because that is something that is manually initiated at the University by the player.