This page contains small description of colony calculations engine. It was checked under 1.31 version of MoO2. Functions IF, ROUNDDOWN, ROUND, ROUNDUP and SQRT used below have the same meaning as in MS Excel or OpenOffice Calc.

## Turn sequence

Each time "Turn" button was pushed next actions take place:

1. Population is increased/decreased.
2. FP/PP/RP/Money are generated.
3. New buildings are constructed.
4. New colonists arrive by freighters (and battles take place).
5. Research projects are finished (and, possibly, spies finish their jobs).

Sometimes it's important to know this sequence. For example, you have the last turn before enemy attacks your colony. Buying some ship or defensive building will help but finishing new technology will not.

## Population growth

Notice that the game interface does not provide all of the information about your population. Only the total population is displayed in the upper right corner of the colony screen. Understanding population based on that statistic may be difficult, especially in cases where a planet has several races.

For example, let's say you have a planet with colonists of two different races and each race has 1.6 million (or 1,600k) creatures. In that case, you will see only one colonist of each race on the colony screen and the total population of 3,200k in the upper right corner.

Population increment is shown the same way. This situation becomes even stranger if you move one colonist from this planet. In that case you will see the only colonist on the colony screen and 2,200k on the upper right corner.

The following formula is used to calculate population growth for each race individually:

``` population_increment =
ROUNDDOWN(
basic_increment * (
100% +
race_bonus +
medicine_bonus +
housing_bonus
) / 100%
) +
IF(cloning center exists, 100, 0) -
food_lack_penalty
```

Basic_increment is the increment for 'normal' race without any bonuses and penalties:

``` basic_increment = ROUNDDOWN( SQRT(2000 * colonist * free_space / planet_capacity) )
```

Where colonist is the total number of colonists of this race present at the planet, planet_capacity is the maximal number of colonists on the planet, free_space is space left for new colonists.

Race_bonus can be -50%, 0%, +50%, +100% (see Master of Orion II: Battle at Antares/Race_design_options);

Medicine_bonus is sum of technology bonus and leader bonus;

``` medicine_bonus =
IF( universal antidote is researched, 50%,
IF( microbiotics is researched, 25%, 0% ) ) +
IF( colony leader is present, medicine skill, 0%);
```

Housing_bonus appears if 'housing' is picked in the build menu:

``` housing_bonus = ROUNDDOWN( PP * 40 / colonist ),
```

Where PP is just the number of production points, colonist is the total number of colonists of this race on the planet

Food_lack_penalty appears when the population do not have enough food or production points (for cybernetic races). For non-cybernetic races:

``` food_lack_penalty = 50 * food_lack
```

For cybernetic races:

``` food_lack_penalty = 25 * food_lack + 25 * production_lack
```

If the colony has colonists of several races, it is not clear how food lack will be divided between them.

### Three ways to grow population

So let's do some analysis of this formulas. Assume that only one race lives in the colony and there is no food penalty. A cloning center improves each of these methods by a flat +100k growth per turn.

The first way of population growth is to use 'natural growth' effectively. That means that 'housing' is not used and the growth rate is defined by basic_increment and some bonuses. Basic_increment depends on population only and reaches the maximum at half of the planet capacity. This maximum is wide - growth rate does not go below 85% of maximal value in a range from 1/4 to 3/4 of the planet capacity. Slowest growth reached at population of 1 or planet_capacity-1 (except trivial case - population does not grow in full colony). Difference between fastest and slowest growth is negligible for small planets and noticeable for big ones. For example slowest and fastest growth differs by 15% for the planet capacity of 4 and differs two times for the planet capacity of 16. 'Natural growth' can be significantly accelerated by leader, race, and medicine bonuses.

You can rearrange population between planets to get maximal increments while all the colonists is still working/farming/researching. The bad thing is that half-populated colonies aren't putting their buildings to full use. Possibly this is the only way early in the game, but it is still slow in any case.

The second way is a 1-populated 'baby factory'. It can generate new colonist in several turns. The main advantage here comes from housing_bonus. For example, abundant colony with automated factory and one colonist of 'normal' race can generate 9 PP per turn. It produces 360% of housing_bonus. But it's not too high! Another example is ultra-rich colony with robotic factory. It will generate 30 PP and get 1200% bonus. In this case all the other bonuses are negligibly small.

This is the cheap and fast method to grow population in competitive game.

The third way is a half-populated 'baby factory'. Big 'housing' planets reaches maximal increments on population 1 or 2 colonists less than half of the capacity. This maximum appears due to two reasons. Firstly, basic_increment reaches maximum on half-populated colonies. Secondly, housing_bonus decreases not very much if colony generates lots PP per worker. Some 'constant' bonuses (leader, medicine, etc.) can increase growth rate, but not greatly. The best way to increase growth here is to eliminate the pollution and increase PP per worker as much as possible. Morale bonuses, leaders with labor skill, microlite constructions and some buildings can be used for this.

This way is expensive. You have to build lots of building, put lots of colonists here... and colony will not produce anything except new colonists! For example, Orion colony (ultra-rich, 25 capacity) with summary morale and leader's labor bonuses up to 60%, with automated factory, deep core mining and +1 PP bonus (microlite construction or race bonus or astro university), with cloning center and without pollution (core waste dumps or tolerant race) will generate 1 colonist per turn. So it is not good idea to use it in competitive game. But this method makes population grow faster (usually 30-50%) than previous one. And it can be useful to get high score in the game.

## Food, production and research points

All the points calculates as a sum of values of 3 kinds:

``` P = P_const + ROUND( P_base + P_bonus )
```

P_const are some point produced permanently by buildings: farming - hydroponic farms +2, subterranean farms +4; production - automated factories +5, robo miners +10, deep core mine +15, robotic factory from +5 for ultra poor to +25 for ultra rich, recyclotron +population (adds population value); research - research laboratory +5, planetary supercomputer +10, galactic cybernet +15, autolab +30.

P_base is sum of colonists number multiplied to 'basic_coeff' over the races;

``` basic_coeff = planet_coeff + race_coeff + tech_coeff + buildings_coeff
```

Planet_coeff depends on a planet type generally; there are two exceptions: biomorphic fungi allows all the 'no farming' colonies produce food with planet_coeff=1; aquatic races has +1 for farming planet_coeff on tundra, ocean and terrain planets.
Race_coeff is depends on racial bonuses.
Tech_coeff depends on got achievements: farming - no bonuses; production - microlite construction +1; research - hightening intelligence +1 to players' race.
Building_coeff generated by buildings: farming - soil enrichment +1, weather controller +2, astro university +1; production - automated factories +1, robo miners +2, deep core mine +3, astro university +1; research - research laboratory +1, planetary supercomputer +2, galactic cybernet +3, astro university +1.

P_bonus is a sum of different bonuses and penalties:

``` P_bonus = P_total - P_colonist - P_pollution
```

P_total is a part of P_base:

``` P_total = C_total * P_base
```

Where C_total is formed by government, morale and colony leader: unification and galactic unification ignores morale and got +50% and +100% for farming and production, for other governments morale just adds to C_total; democracy (federation) and feudal (confederation) got +50 (+75%) and -50% (-25%) to research; leader skills adds to C_total.
P_colonist is a sum of penalties for each colonist (it is calculated for each colonist and can be presented in two equal forms: as a part of P_base for some group of colonists, or as a part of basic_coeff for each colonist separately): conquered colonists got 25% penalty; if colony has 'wrong' gravity for the race and has no gravity generator, colonist got 25% or 50% penalty; blockaded colony has penalty 50% for farming and production.

Production has extra penalty - pollution. It is calculated as:

``` pollution = ROUNDUP( ROUND( PP_base + PP_bonus ) / pollution_divisor * leader_coeff * tolerance - planet_size ),
```

Where ROUND( PP_base + PP_bonus ) is a part of PP except the constantly produced by buildings PP_const. Pollution_divisor defines basic amount of pollution:

``` pollution_divisor = 2 * IF( pollution processor is built, 2, 1 ) * IF( atmospheric renewer is built, 4, 1 )
```

Leader can remove part of pollution:

``` leader_coeff = ( 100% - value_of_environmentalist_skill ) / 100%
```

Tolerance = 1 - tolerant_population / total_population - is a part of non-tolerant population (so, fully tolerant population does not generate pollution). Planet_size is in a range from 1 to tiny to 5 for huge planets, nano disassemblers increases this value two times. Negative pollution is ignored. Core waste dumps removes any pollution.

## Money generation

Money generation looks to be calculated in a little bit different way - rounding take place for each bonus separately:

``` income = special_income + population_income + bonus_income - building_maintenance
```

Special_income appears on planets with gold (+5) and gem (+10) deposits.

Population income is generated by colonists:

``` population_income = ROUND( population * ( 1 + race_bonus ) )
```

Where population is a colonists number;

Race_bonus was chosen while race was designed, but it affects all the races in the empire; values of race_bonus can be -0.5, 0, +0.5 and +1 BC/colonist.

Bonus_income is a sum of bonuses, generated by buildings, techs, morale and leader:

``` bonus_income =
space_port_bonus + stock_exchange_bonus + galactic_currency_exchange_bonus + government_bonus +
ROUND( population_income * morale ) +
```

Bonuses for buildings and techs calculated not by ROUND, but by ROUNDDOWN:

``` x_bouns = IF( x exists/researched, ROUNDDOWN( (special_income+population_income) * x_coeff ), 0 )
```

Where x_coeff are 0.5 for space port - space_port_bonus, 1 for stock_exchange - stock_exchange_bonus, 0.5 for galactic currency exchange - galactic_currency_exchange_bonus, and 0.5 (0.75) for democracy (federation) - government_bonus.

``` building_maintenance = ROUND( building_maintenance_base * maintenance_coeff )
```

Where building_maintenance_base - is a sum of maintenance over all the buildings on a planet. Maintenance_coeff depends on climate, there are 50% penalty for toxic and 25% for radiated and desert.

## Cost of buying production points

X is a number of PP to make the thing, and Y is already produced PP.

Complete, Y/X Cost Cost decrement
0% 4*X
0 - 10% 4*X - 10*Y -10 BC/PP
10% 3*X
10 - 50% 3.5*X - 5*Y -5 BC/PP
50% X
50 - 100% 2*X - 2*Y -2 BC/PP
100% 0