Dusty
Chieftain
In working on MapCopy I became obsessed with figuring out how Civ 2 calculates fertility. My obsession didn't last long enough to figure it all out, but here's what I found.
As Wobbegong posted, the tile itself, the inner city radius ring and outer city radius ring are weighted differently. So the total food/shield/trade production is calculated like:
The production for each square is from RULES.TXT, except when calculating shields for grassland squares. A grassland square with a shield has production of 1 with regards to fertility. If there is no shield, then the grassland square has a shield production of 0 with regards to fertility. The value in RULES.TXT for grassland shield production does not seem to affect fertility.
If a square can be irrigated a bonus is added to its food production. The value seems to be the floating point representation of 2/3. Note that the full floating point representation is needed. 0.67 is not good enough. For mining, a bonus of 0.5 is added to shield production. I'm a little suspicious of these values because I discovered them empircally. There could very well be test cases that I didn't try which disprove these values. Note that the value of the irrigation/mining bonus in RULES.txt does not matter, it can be 0 and the bonuses above are still used for calculating fertility. Also, if a square supports both mining and irrigation, then only the irrigation bonus applies for calculating fertility.
The fertility value is then calculated using the following formula, rounded to the nearest integer:
Then there is another special case. If the square in question is a grassland without a shield, the fertility is decremented by 1. Finally the fertility value is forced to be between 8 and 15.
In all of my tests, this seems to work, but there's probably a test case out there that disproves me. Also, all of my tests have been done with special resources supressed. I didn't have time to figure out how resources affect fertility.
As Wobbegong posted, the tile itself, the inner city radius ring and outer city radius ring are weighted differently. So the total food/shield/trade production is calculated like:
Code:
total production = (self production * 4) +
(inner ring production * 2) +
(outer ring production)
The production for each square is from RULES.TXT, except when calculating shields for grassland squares. A grassland square with a shield has production of 1 with regards to fertility. If there is no shield, then the grassland square has a shield production of 0 with regards to fertility. The value in RULES.TXT for grassland shield production does not seem to affect fertility.
If a square can be irrigated a bonus is added to its food production. The value seems to be the floating point representation of 2/3. Note that the full floating point representation is needed. 0.67 is not good enough. For mining, a bonus of 0.5 is added to shield production. I'm a little suspicious of these values because I discovered them empircally. There could very well be test cases that I didn't try which disprove these values. Note that the value of the irrigation/mining bonus in RULES.txt does not matter, it can be 0 and the bonuses above are still used for calculating fertility. Also, if a square supports both mining and irrigation, then only the irrigation bonus applies for calculating fertility.
The fertility value is then calculated using the following formula, rounded to the nearest integer:
Code:
(total food * 3) + (total shields * 2) + (total trade)
------------------------------------------------------
16
Then there is another special case. If the square in question is a grassland without a shield, the fertility is decremented by 1. Finally the fertility value is forced to be between 8 and 15.
In all of my tests, this seems to work, but there's probably a test case out there that disproves me. Also, all of my tests have been done with special resources supressed. I didn't have time to figure out how resources affect fertility.