[Freeciv-Dev] Re: (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 >
> > 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.
>
> Interesting idea. Is there a way to get this
> behavior without adding a
> new setting? It's okay that a steepness of 0 gives
> no hills; we can
> change the scale of the current settings so long as
> their basic meanings
> remain intact.
OK, revision 2 of the patch does this. Unfortunately
it has an awkward way of finding latitude. I am
curious if there is simple and easy way to find a
linear measure of how far a tile is between the
equator and the pole. This is easy in projection 1;
in projections such as 3, where you wrap both N-S and
E-W, I could not find a simple way to do this.
Brian
__________________________________
Do you Yahoo!?
Plan great trips with Yahoo! Travel: Now over 17,000 guides!
http://travel.yahoo.com/p-travelguide
diff -Nur -Xfreeciv/diff_ignore freeciv/server/generator/mapgen.c
freeciv_altered2/server/generator/mapgen.c
--- freeciv/server/generator/mapgen.c 2005-04-15 15:51:11.051579152 -0400
+++ freeciv_altered2/server/generator/mapgen.c 2005-04-15 21:45:46.061286064
-0400
@@ -190,6 +190,10 @@
int thill, int my_height)
{
int higher_than_me = 0;
+
+ /* when steepness is very low, it's ok to get unending flatlands */
+ if(map.steepness <= 15) return FALSE;
+
square_iterate(ptile, 2, tile1) {
if (hmap(tile1) > thill) {
return FALSE;
@@ -220,6 +224,10 @@
static bool terrain_is_too_high(struct tile *ptile,
int thill, int my_height)
{
+
+ /* when steepness is very high, it's ok to get unending mountains */
+ if(map.steepness >= 85) return FALSE;
+
square_iterate(ptile, 1, tile1) {
if (hmap(tile1) + (hmap_max_level - hmap_mountain_level) / 5 < thill) {
return FALSE;
@@ -357,7 +365,7 @@
} else if (tmap_is(ptile, TT_COLD)) {
map_set_terrain(ptile, T_TUNDRA);
} else {
- if (myrand(100) > 50) {
+ if(myrand(99) < map.wetness) {
map_set_terrain(ptile, T_GRASSLAND);
} else {
map_set_terrain(ptile, T_PLAINS);
@@ -1136,26 +1144,49 @@
**************************************************************************/
static void adjust_terrain_param(void)
{
+
+#define SQR(x) ((x)*(x))
+
int polar = 2 * ICE_BASE_LEVEL * map.landpercent / MAX_COLATITUDE ;
float factor = (100.0 - polar - map.steepness * 0.8 ) / 10000;
+ int remaining = 0;
+
+ /* this must be done to prevent div0 errors later on */
+ int t = MIN(map.temperature, 99);
+
+ int steep_sqrt = (int)(100.0 *
+ sqrt((float)map.steepness / 100.0));
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);
+
+ /* Make sure terrain proportions come out close to what you'd expect:
+ * No deserts on wet planets, no swamps on dry ones,
+ * no jungles on frozen ones. Interpolate as necessary */
+
+ river_pct = SQR(map.wetness) / SQR(100);
+ remaining = 100 - mountain_pct;
+
+ /* forests: adaptable. prefer terrain steep or wet */
+ forest_pct = (steep_sqrt + map.wetness)/2;
+ forest_pct = (remaining*forest_pct)/100;
+ remaining -= forest_pct;
+
+ /* jungles: require terrain hot. Prefer either wet or steep */
+ jungle_pct = (forest_pct * SQR(t)) / SQR(100);
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)) ;
+
+ /* deserts: require terrain hot and dry */
+ desert_pct = (SQR(t) * remaining) / SQR(100);
+ desert_pct = (SQR(100 - map.wetness) * desert_pct) / SQR(100);
+ remaining -= desert_pct;
+
+ /* swamp: prefer terrain hot and wet. Require terrain flat */
+ swamp_pct = (t*map.wetness*remaining) / SQR(100);
+ swamp_pct = (swamp_pct * SQR(100-steep_sqrt)) / SQR(100);
+ remaining -= swamp_pct;
+
+#undef SQR
}
/****************************************************************************
diff -Nur -Xfreeciv/diff_ignore freeciv/server/generator/temperature_map.c
freeciv_altered2/server/generator/temperature_map.c
--- freeciv/server/generator/temperature_map.c 2005-04-15 15:51:11.050579304
-0400
+++ freeciv_altered2/server/generator/temperature_map.c 2005-04-15
21:25:55.856224736 -0400
@@ -73,6 +73,8 @@
{
int i;
+#define SQR(x) ((x)*(x))
+
/* if map is defined this is not changed */
/* TO DO load if from scenario game with tmap */
assert(temperature_map == NULL); /* to debug, never load a this time */
@@ -82,13 +84,40 @@
temperature_map = fc_malloc(sizeof(*temperature_map) * MAP_INDEX_SIZE);
whole_map_iterate(ptile) {
-
- /* the base temperature is equal to base map_colatitude */
- int t = map_colatitude(ptile);
+
+ /* to the extent planetary 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 */
+ int planetary_temperature = (map.temperature * MAX_COLATITUDE)/100;
+ int harshness = SQR(100-2*map.temperature);
+ int mildness = SQR(100) - harshness;
+
+ /* the base temperature is equal to base map_colatitude */
+ int t = map_colatitude(ptile);
+
+ /* map_colatitude appears to give the area between the given tile's
+ * latitude and the nearest pole. We need the latitude directly;
+ * for non-mercator projections, this means taking the inverse
+ * of the integral for area over a sphere. This is not easy, so
+ * we will approximate with a pyramid instead. With a pyramid,
+ * the inverse latitude (distance from pole in latitude units)
+ * is proportional to the square root of the area between that
+ * latitude and the pole.
+ * If someone knows a better, simpler, and more to the point,
+ * accurate way of finding latitude, don't hesitate to send
+ * a patch to bugs@xxxxxxxxxxx */
+ float f_colatitude = (float)t / (float)MAX_COLATITUDE;
+ if(topo_has_flag(TF_WRAPY)) {
+ t = (int)(sqrt(f_colatitude) * (float)MAX_COLATITUDE);
+ }
+
+ t += ((harshness * planetary_temperature) + (mildness * t)) / SQR(100);
+ t /= 2;
+
if (!real) {
tmap(ptile) = t;
} else {
- /* height land can be 30% collest */
+ /* high land can be 30% cooller */
float height = - 0.3 * MAX(0, hmap(ptile) - hmap_shore_level)
/ (hmap_max_level - hmap_shore_level);
/* near ocean temperature can be 15 % more "temperate" */
@@ -99,13 +128,7 @@
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) {
- adjust_int_map(temperature_map, MAX_COLATITUDE);
- }
+
/* now simplify to 4 base values */
for (i = 0; i < MAP_INDEX_SIZE; i++) {
int t = temperature_map[i];
@@ -120,4 +143,6 @@
temperature_map[i] = TT_FROZEN;
}
}
+
+#undef SQR
}
- [Freeciv-Dev] Re: (PR#12806) idea: harsh climate generator, Jason Short, 2005/04/15
- [Freeciv-Dev] Re: (PR#12806) idea: harsh climate generator, Benoit Hudson, 2005/04/15
- [Freeciv-Dev] Re: (PR#12806) idea: harsh climate generator, Brian Dunstan, 2005/04/15
- [Freeciv-Dev] Re: (PR#12806) idea: harsh climate generator,
Brian Dunstan <=
- [Freeciv-Dev] Re: (PR#12806) idea: harsh climate generator, Jason Short, 2005/04/16
- [Freeciv-Dev] Re: (PR#12806) idea: harsh climate generator, Brian Dunstan, 2005/04/16
- [Freeciv-Dev] Re: (PR#12806) idea: harsh climate generator, Peter Schaefer, 2005/04/17
- [Freeciv-Dev] Re: (PR#12806) idea: harsh climate generator, Brian Dunstan, 2005/04/17
- [Freeciv-Dev] Re: (PR#12806) idea: harsh climate generator, Brian Dunstan, 2005/04/17
|
|