[Freeciv-Dev] (PR#12806) idea: harsh climate generator
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12806 >
I have noticed that even with extreme settings e.g.
temperature=0, you do not get extreme results with the
terrain generator. I am sure this is by design, but
some users may want to create an ice planet, or desert
planet, perhaps for a scenario.
The attached patch adds a setting (under 'rare'),
harshclimate, that will take the climate settings
literally. Literally meaning, no hills when steepness
is zero, no deserts when wetness is 100, etc.
Also: I have noticed that sometimes the river
generator will move a river from a non-hill square
(e.g. jungle), to a hill sqare, and then off again.
This seems to defy common sense. I think it is
because the height map views the river as moving from
a high-elevation jungle, to a lower elevation hill, to
still lower elevation. It still looks very odd
however. I am wondering if this behavior is unwelcome
(i.e. should I bother making a patch for it)
__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/
diff -Nur -Xfreeciv/diff_ignore freeciv/common/map.h
freeciv_altered/common/map.h
--- freeciv/common/map.h 2005-04-15 10:33:38.364027920 -0400
+++ freeciv_altered/common/map.h 2005-04-15 13:38:53.221312776 -0400
@@ -109,6 +109,7 @@
bool tinyisles;
bool separatepoles;
bool alltemperate;
+ bool harshclimate;
int temperature;
int wetness;
int steepness;
@@ -594,6 +595,10 @@
#define MAP_MIN_ALLTEMPERATE FALSE
#define MAP_MAX_ALLTEMPERATE TRUE
+#define MAP_DEFAULT_HARSHCLIMATE FALSE
+#define MAP_MIN_HARSHCLIMATE FALSE
+#define MAP_MAX_HARSHCLIMATE TRUE
+
#define MAP_DEFAULT_TEMPERATURE 50
#define MAP_MIN_TEMPERATURE 0
#define MAP_MAX_TEMPERATURE 100
diff -Nur -Xfreeciv/diff_ignore freeciv/server/generator/mapgen.c
freeciv_altered/server/generator/mapgen.c
--- freeciv/server/generator/mapgen.c 2005-04-15 10:33:38.185055128 -0400
+++ freeciv_altered/server/generator/mapgen.c 2005-04-15 14:40:22.576445544
-0400
@@ -190,6 +190,12 @@
int thill, int my_height)
{
int higher_than_me = 0;
+
+ /* Harsh climate: when steepness is set very low, it's ok to get
+ * unending flatlands. */
+ if(map.harshclimate &&
+ map.steepness <= 15) return FALSE;
+
square_iterate(ptile, 2, tile1) {
if (hmap(tile1) > thill) {
return FALSE;
@@ -213,13 +219,19 @@
/**************************************************************************
we don't want huge areas of hill/mountains,
- so we put in a plains here and there, where it gets too 'heigh'
+ so we put in a plains here and there, where it gets too 'high'
Return TRUE if the terrain at the given map position is too heigh.
****************************************************************************/
static bool terrain_is_too_high(struct tile *ptile,
int thill, int my_height)
{
+
+ /* Harsh climate -- when steepness is set very high, it's ok to get
+ * unending mountains. */
+ if(map.harshclimate &&
+ map.steepness >= 85) return FALSE;
+
square_iterate(ptile, 1, tile1) {
if (hmap(tile1) + (hmap_max_level - hmap_mountain_level) / 5 < thill) {
return FALSE;
@@ -357,10 +369,24 @@
} else if (tmap_is(ptile, TT_COLD)) {
map_set_terrain(ptile, T_TUNDRA);
} else {
- if (myrand(100) > 50) {
- map_set_terrain(ptile, T_GRASSLAND);
- } else {
- map_set_terrain(ptile, T_PLAINS);
+
+ /* Harsh climate: do not place grasslands on dry maps.
+ * Do not place plains on wet maps. */
+ if(map.harshclimate) {
+ if(myrand(99) < map.wetness) {
+ map_set_terrain(ptile, T_GRASSLAND);
+ }
+ else {
+ map_set_terrain(ptile, T_PLAINS);
+ }
+ }
+ /* Normal climate: random choice between plains, grassland */
+ else {
+ if (myrand(100) > 50) {
+ map_set_terrain(ptile, T_GRASSLAND);
+ } else {
+ map_set_terrain(ptile, T_PLAINS);
+ }
}
}
map_set_placed(ptile);
@@ -1142,20 +1168,58 @@
mountain_pct = factor * map.steepness * 90;
- /* 27 % if wetness == 50 & */
- forest_pct = factor * (map.wetness * 40 + 700) ;
- jungle_pct = forest_pct * (MAX_COLATITUDE - TROPICAL_LEVEL) /
- (MAX_COLATITUDE * 2);
- forest_pct -= jungle_pct;
-
- /* 3 - 11 % */
- river_pct = (100 - polar) * (3 + map.wetness / 12) / 100;
-
- /* 6 % if wetness == 50 && temperature == 50 */
- swamp_pct = factor * MAX(0,
- (map.wetness * 9 - 150 + map.temperature * 6));
- desert_pct =factor * MAX(0,
- (map.temperature * 15 - 250 + (100 - map.wetness) * 10)) ;
+ /* Harsh climate: use literal meaning of wetness, dryness,
+ * steepness settings. No deserts on wet planets, no
+ * swamps on dry ones, no jungles on frozen ones */
+ if(map.harshclimate) {
+
+ int remaining = 0;
+
+ /* this must be done to prevent errors later on */
+ int t = MIN(map.temperature, 99);
+
+#define SQR(x) ((x)*(x))
+
+ river_pct = SQR(map.wetness) / SQR(100);
+ remaining = 100 - mountain_pct;
+
+ /* forests: prefer terrain steep or wet */
+ forest_pct = (map.steepness + map.wetness)/2;
+ forest_pct = (remaining*forest_pct)/100;
+ remaining -= forest_pct;
+
+ /* jungles: prefer terrain hot, and either wet or steep */
+ jungle_pct = (forest_pct * SQR(t)) / SQR(100);
+ forest_pct -= jungle_pct;
+
+ /* deserts: prefer terrain hot and dry */
+ desert_pct = (t*(100-map.wetness) * remaining) / SQR(100);
+ remaining -= desert_pct;
+
+ /* swamp: prefer terrain hot, wet, and flat */
+ swamp_pct = (map.wetness * (100 - map.steepness) * remaining) / SQR(100);
+ remaining -= swamp_pct;
+
+#undef SQR
+ }
+ else {
+
+ forest_pct = factor * (map.wetness * 40 + 700) ;
+ jungle_pct = forest_pct * (MAX_COLATITUDE - TROPICAL_LEVEL) /
+ (MAX_COLATITUDE * 2);
+ forest_pct -= jungle_pct;
+
+
+ river_pct = (100 - polar) * (3 + map.wetness / 12) / 100;
+
+
+ swamp_pct =
+ factor * MAX(0, (map.wetness * 9 - 150 + map.temperature * 6));
+ desert_pct =
+ factor * MAX(0, (map.temperature * 15 - 250 + (100 - map.wetness) * 10));
+
+ }
+
}
/****************************************************************************
diff -Nur -Xfreeciv/diff_ignore freeciv/server/generator/temperature_map.c
freeciv_altered/server/generator/temperature_map.c
--- freeciv/server/generator/temperature_map.c 2005-04-15 10:33:38.172057104
-0400
+++ freeciv_altered/server/generator/temperature_map.c 2005-04-15
15:05:32.000978136 -0400
@@ -85,6 +85,21 @@
/* the base temperature is equal to base map_colatitude */
int t = map_colatitude(ptile);
+
+ /* harsh climate: to the extent temperature differs from 50,
+ * expand influence of very low planet temperatures to the equator,
+ * and the influence of very high planet temperature to the poles */
+ if(map.harshclimate) {
+#define SQR(x) ((x)*(x))
+ int planetary_temperature = (map.temperature * MAX_COLATITUDE)/100;
+ int harshness = SQR(100-2*map.temperature);
+ int mildness = SQR(100) - harshness;
+
+ t += ((harshness * planetary_temperature) + (mildness * t)) /
+ (2*SQR(100));
+#undef SQR
+ }
+
if (!real) {
tmap(ptile) = t;
} else {
@@ -95,15 +110,16 @@
float temperate = 0.15 * (map.temperature / 100 - t / MAX_COLATITUDE) *
2 * MIN (50 ,count_ocean_near_tile(ptile, FALSE, TRUE)) /
100;
-
- tmap(ptile) = t * (1.0 + temperate) * (1.0 + height);
+
+ tmap(ptile) = t * (1.0 + temperate) * (1.0 + height);
}
} whole_map_iterate_end;
/* adjust to get well sizes frequencies */
/* Notice: if colatitude is load from a scenario never call adjust has
scenario maybe has a odd colatitude ditribution and adjust will
brack it */
- if (!map.alltemperate) {
+ if (!map.alltemperate
+ && !map.harshclimate) {
adjust_int_map(temperature_map, MAX_COLATITUDE);
}
/* now simplify to 4 base values */
@@ -119,5 +135,5 @@
} else {
temperature_map[i] = TT_FROZEN;
}
- }
+ }
}
diff -Nur -Xfreeciv/diff_ignore freeciv/server/settings.c
freeciv_altered/server/settings.c
--- freeciv/server/settings.c 2005-04-15 10:33:38.105067288 -0400
+++ freeciv_altered/server/settings.c 2005-04-15 13:38:53.225312168 -0400
@@ -293,6 +293,18 @@
N_("0 = normal Earth-like planet; 1 = all-temperate planet "),
NULL, MAP_DEFAULT_ALLTEMPERATE)
+ GEN_BOOL("harshclimate", map.harshclimate,
+ SSET_MAP_GEN, SSET_GEOLOGY, SSET_RARE, SSET_TO_CLIENT,
+ N_("Allows extreme climates"),
+ N_("Applies climate settings literally. For example, "
+ "steepness=0 indicates that there are no hills or "
+ "mountains. Wetness=0 will mean the planet is mostly "
+ "desert, with no swamps, forests, or jungles. Setting "
+ "temperature=0 will lead to a planet almost completely "
+ "composed of arctic and tundra.\n"
+ "0 - standard climate. 1 - allow climate extremes"),
+ NULL, MAP_DEFAULT_HARSHCLIMATE)
+
GEN_INT("temperature", map.temperature,
SSET_MAP_GEN, SSET_GEOLOGY, SSET_SITUATIONAL, SSET_TO_CLIENT,
N_("Average temperature of the planet"),
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#12806) idea: harsh climate generator,
Brian Dunstan <=
|
|