Refar
Deity
- Joined
- Apr 10, 2005
- Messages
- 4,608
I took a look at the new Global Warming code. Here's how it works (Unless of course me missing something or just beeing a moron).
The XML tags:
All found in GlobalDefines.XML. New ones are highlighted (At least i think those are new).
Other variables involved:
#LAND - The number of land Plots on the map.
#PLOTS - The number of plots in the map (Width x Height)
#FOREST - The number of forest/jungle tiles on the map.
Actually features with (getGrowthProbability() > 0) are counted. For default
game those are Jungle and Forest. Might be different in mods.
#BADLAND - Land plots not giving any yield (Desert, Frozen land).
#BAD_HEALTH - The global caused by buildings. The from overpopulation, features or other possible sources does not count.
??? I do not know yet, if the 2 from power does count here or not. I assume it does. ???
#NUKES_EXPLODED - The number of Nukes ever exploded. This count for any kind of nuclear explosion - ICBM, Tactical Nuke and Plant Meltdown.
Derived Variables:
The code on Global Warming is within CvCity.cpp; doGlobalWarming();
GW_DEFENSE = #FOREST / #LAND * GLOBAL_WARMING_FOREST
GW_VALUE = #BAD_HEALTH * GLOBAL_WARMING_UNHEALTH_WEIGHT / #_PLOTS + #NUKES_EXPLODED * GLOBAL_WARMING_NUKE_WEIGHT / 100
Global Warming Probability:
On every turn there will be GW_VALUE indipendant random tests, each with a
probability to cause Global Warming:
PROB1 = ( GLOBAL_WARMING_PROB - GW_DEFENSE ) / 100
This results in a chance of no GW at a given turn:
PROBtotal_no_GW = (1 - PROB1)GW_VALUE
And hence the chance of at least one GW event on any given turn:
PROBGW_strikes = 1 - (1 - PROB1)GW_VALUE
With the standard XML values:
GW_DEFENSE = #_FOREST / #_LAND * 50
GW_VALUE = - #_BUILDING_BAD_HEALTH / #_PLOTS * 20 + #_NUCLEAR_EXPLOSIONS * 1/2
PROBGW_strikes = 1 - (0.8 + #FOREST/#LAND * 0.5)GW_VALUE
Effect of Global Warming
If Global Warming strikes a random land PLOT, which is not a city will be choosen.
There is no regional, player, team or other bias in choosing the target plot for Global Warming. It does not matter who, where or why caused the nuclear explosions, built the polluting buildings, chopped or preserved the forests.
If PLOT has a feature (Forest, Jungle, FloodPlain, Oasis), this feature will be removed, but the terrain type does not change. (Unless the feature is Fallout, in which case nothing happens at all)
If PLOT has no Feature and can give any yield (i.e. is not desert or fozen), then it will be turned into GLOBAL_WARMING_TERRAIN, which is - per standard XML - desert.
Note on probability: This de facto reduces the Probability of Global Warming with increasing amount of useless land plots on the map. Since if a plot is choosen to be victim of Global Warming, that can not be worked anyway, nothing happens. So actually
PROBGW_strikes = 1 - (1 - PROB1 + PROB1*#BADLAND/#LAND)GW_VALUE
Depending on how high PROB1 actually is and how much "bad land" we have it might result in 5 ~ 10 % (Or even more in really extreme cases) less visible GW.
Same thing with fallout. Should be negligible in most games, but could become interesting in a huge Nuclear War, where the Fallout will actually help preserve the terrain under it. Tho of course, as soon as you clear the Fallout after the war, the plots will become affected by Global Warming again.
Notes:
Nukes now count only half. This means that a single explosion (say a meltdown) will not cause GW by itself. However this is only true if there are no other sources of GW.
The from buildings is weighted by map size (Number of plots). To give a idea of its impact let assume a Standard Size map
1 * 20 / 4368 = ~0.005
So ~110 from buildings would have the same effect as one Nuke, giving us a half of a GW_VALUE point.
Also since there is integer divison involved and assuming no nukes, the first ~220 are free (as long as #BAD_HEALTH * GLOBAL_WARMING_UNHEALTH_WEIGHT / #_PLOTS < 1).
One city with all possible pollution sorces and no Recycling Center can "provide" 17 (i might be mistaken by +/- one or two here).
Green World
To completely avoid Global Warming we would need
A) Never get GW_VALUE >= 1. As mentioned above this could still allow one nuke explosion and/or some very minor building or
B) Have enought forests to make PROB1 drop to 0. At standard XML values this would require 40% of the landmass to be covered with Forest or Jungle.
Modding
Setting GLOBAL_WARMING_PROB = 0 will still remove all GW (Tho the method examining all plots and cities will still run... Would be a bit faster, to put a check there and skip the rest if == 0).
GLOBAL_WARMING_FOREST is a positive modifier - increasing the value will make less Forests/Jungles needed to avoid GW. Say a GLOBAL_WARMING_FOREST = 100 would make only 20% of forested Landmass needed to count as a green planet.
Also note again - while talking FOREST we actually mean all Features that can grow.
GLOBAL_WARMING_UNHEALTH_WEIGHT and GLOBAL_WARMING_NUKE_WEIGHT are negative modifiers - reducing those will result in less Global Warming events.
The XML tags:
All found in GlobalDefines.XML. New ones are highlighted (At least i think those are new).
Code:
<Define>
<DefineName>GLOBAL_WARMING_TERRAIN</DefineName>
<DefineTextVal>TERRAIN_DESERT</DefineTextVal>
</Define>
<Define>
<DefineName>GLOBAL_WARMING_PROB</DefineName>
<iDefineIntVal>20</iDefineIntVal>
</Define>
<Define>
<DefineName>[B][COLOR="SeaGreen"]GLOBAL_WARMING_FOREST[/COLOR][/B]</DefineName>
<iDefineIntVal>50</iDefineIntVal>
</Define>
<Define>
<DefineName>[B][COLOR="SeaGreen"]GLOBAL_WARMING_UNHEALTH_WEIGHT[/COLOR][/B]</DefineName>
<iDefineIntVal>20</iDefineIntVal>
</Define>
<Define>
<DefineName>[B][COLOR="SeaGreen"]GLOBAL_WARMING_NUKE_WEIGHT[/COLOR][/B]</DefineName>
<iDefineIntVal>50</iDefineIntVal>
</Define>
#LAND - The number of land Plots on the map.
#PLOTS - The number of plots in the map (Width x Height)
#FOREST - The number of forest/jungle tiles on the map.
Actually features with (getGrowthProbability() > 0) are counted. For default
game those are Jungle and Forest. Might be different in mods.
#BADLAND - Land plots not giving any yield (Desert, Frozen land).
#BAD_HEALTH - The global caused by buildings. The from overpopulation, features or other possible sources does not count.
??? I do not know yet, if the 2 from power does count here or not. I assume it does. ???
#NUKES_EXPLODED - The number of Nukes ever exploded. This count for any kind of nuclear explosion - ICBM, Tactical Nuke and Plant Meltdown.
Derived Variables:
The code on Global Warming is within CvCity.cpp; doGlobalWarming();
GW_DEFENSE = #FOREST / #LAND * GLOBAL_WARMING_FOREST
GW_VALUE = #BAD_HEALTH * GLOBAL_WARMING_UNHEALTH_WEIGHT / #_PLOTS + #NUKES_EXPLODED * GLOBAL_WARMING_NUKE_WEIGHT / 100
Global Warming Probability:
On every turn there will be GW_VALUE indipendant random tests, each with a
probability to cause Global Warming:
PROB1 = ( GLOBAL_WARMING_PROB - GW_DEFENSE ) / 100
This results in a chance of no GW at a given turn:
PROBtotal_no_GW = (1 - PROB1)GW_VALUE
And hence the chance of at least one GW event on any given turn:
PROBGW_strikes = 1 - (1 - PROB1)GW_VALUE
With the standard XML values:
GW_DEFENSE = #_FOREST / #_LAND * 50
GW_VALUE = - #_BUILDING_BAD_HEALTH / #_PLOTS * 20 + #_NUCLEAR_EXPLOSIONS * 1/2
PROBGW_strikes = 1 - (0.8 + #FOREST/#LAND * 0.5)GW_VALUE
Effect of Global Warming
If Global Warming strikes a random land PLOT, which is not a city will be choosen.
There is no regional, player, team or other bias in choosing the target plot for Global Warming. It does not matter who, where or why caused the nuclear explosions, built the polluting buildings, chopped or preserved the forests.
If PLOT has a feature (Forest, Jungle, FloodPlain, Oasis), this feature will be removed, but the terrain type does not change. (Unless the feature is Fallout, in which case nothing happens at all)
If PLOT has no Feature and can give any yield (i.e. is not desert or fozen), then it will be turned into GLOBAL_WARMING_TERRAIN, which is - per standard XML - desert.
Note on probability: This de facto reduces the Probability of Global Warming with increasing amount of useless land plots on the map. Since if a plot is choosen to be victim of Global Warming, that can not be worked anyway, nothing happens. So actually
PROBGW_strikes = 1 - (1 - PROB1 + PROB1*#BADLAND/#LAND)GW_VALUE
Depending on how high PROB1 actually is and how much "bad land" we have it might result in 5 ~ 10 % (Or even more in really extreme cases) less visible GW.
Same thing with fallout. Should be negligible in most games, but could become interesting in a huge Nuclear War, where the Fallout will actually help preserve the terrain under it. Tho of course, as soon as you clear the Fallout after the war, the plots will become affected by Global Warming again.
Notes:
Nukes now count only half. This means that a single explosion (say a meltdown) will not cause GW by itself. However this is only true if there are no other sources of GW.
The from buildings is weighted by map size (Number of plots). To give a idea of its impact let assume a Standard Size map
1 * 20 / 4368 = ~0.005
So ~110 from buildings would have the same effect as one Nuke, giving us a half of a GW_VALUE point.
Also since there is integer divison involved and assuming no nukes, the first ~220 are free (as long as #BAD_HEALTH * GLOBAL_WARMING_UNHEALTH_WEIGHT / #_PLOTS < 1).
One city with all possible pollution sorces and no Recycling Center can "provide" 17 (i might be mistaken by +/- one or two here).
Green World
To completely avoid Global Warming we would need
A) Never get GW_VALUE >= 1. As mentioned above this could still allow one nuke explosion and/or some very minor building or
B) Have enought forests to make PROB1 drop to 0. At standard XML values this would require 40% of the landmass to be covered with Forest or Jungle.
Modding
Setting GLOBAL_WARMING_PROB = 0 will still remove all GW (Tho the method examining all plots and cities will still run... Would be a bit faster, to put a check there and skip the rest if == 0).
GLOBAL_WARMING_FOREST is a positive modifier - increasing the value will make less Forests/Jungles needed to avoid GW. Say a GLOBAL_WARMING_FOREST = 100 would make only 20% of forested Landmass needed to count as a green planet.
Also note again - while talking FOREST we actually mean all Features that can grow.
GLOBAL_WARMING_UNHEALTH_WEIGHT and GLOBAL_WARMING_NUKE_WEIGHT are negative modifiers - reducing those will result in less Global Warming events.