Skip to content

Commit 8180b2e

Browse files
committed
Added some mountain levels and made satellite-map mountain-levels dynamic.
Updated World.proto and World_pb2.py.
1 parent d00788b commit 8180b2e

File tree

7 files changed

+200
-180
lines changed

7 files changed

+200
-180
lines changed

worldengine/World.proto

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -57,62 +57,65 @@ message World {
5757
required int32 height = 5;
5858

5959
// Elevation
60-
required DoubleMatrix heightMapData = 6;
61-
required double heightMapTh_sea = 7;
62-
required double heightMapTh_plain = 8;
63-
required double heightMapTh_hill = 9;
60+
required DoubleMatrix heightMapData = 6;
61+
required double heightMapTh_sea = 7;
62+
required double heightMapTh_plain = 8;
63+
required double heightMapTh_hill = 9;
64+
required double heightMapTh_low_mountain = 10;
65+
required double heightMapTh_med_mountain = 11;
66+
required double heightMapTh_high_mountain = 12;
6467

6568
// Plates
66-
required IntegerMatrix plates = 10;
69+
required IntegerMatrix plates = 13;
6770

6871
// Ocean
69-
required BooleanMatrix ocean = 11;
70-
required DoubleMatrix sea_depth = 12;
72+
required BooleanMatrix ocean = 14;
73+
required DoubleMatrix sea_depth = 15;
7174

7275
// Biome
73-
optional IntegerMatrix biome = 13;
76+
optional IntegerMatrix biome = 16;
7477

7578
// Humidity
76-
optional DoubleMatrixWithQuantiles humidity = 14;
79+
optional DoubleMatrixWithQuantiles humidity = 17;
7780

7881
// Irrigation
79-
optional DoubleMatrix irrigation = 15;
82+
optional DoubleMatrix irrigation = 18;
8083

8184
// Permeability
82-
optional DoubleMatrix permeabilityData = 16;
83-
optional double permeability_low = 17;
84-
optional double permeability_med = 18;
85+
optional DoubleMatrix permeabilityData = 19;
86+
optional double permeability_low = 20;
87+
optional double permeability_med = 21;
8588

8689
// Watermap
87-
optional DoubleMatrix watermapData = 19;
88-
optional double watermap_creek = 20;
89-
optional double watermap_river = 21;
90-
optional double watermap_mainriver = 22;
90+
optional DoubleMatrix watermapData = 22;
91+
optional double watermap_creek = 23;
92+
optional double watermap_river = 24;
93+
optional double watermap_mainriver = 25;
9194

9295
// Precipitation
93-
optional DoubleMatrix precipitationData = 23;
94-
optional double precipitation_low = 24;
95-
optional double precipitation_med = 25;
96+
optional DoubleMatrix precipitationData = 26;
97+
optional double precipitation_low = 27;
98+
optional double precipitation_med = 28;
9699

97100
// Temperature
98-
optional DoubleMatrix temperatureData = 26;
99-
optional double temperature_polar = 27;
100-
optional double temperature_alpine = 28;
101-
optional double temperature_boreal = 29;
102-
optional double temperature_cool = 30;
103-
optional double temperature_warm = 31;
104-
optional double temperature_subtropical = 32;
101+
optional DoubleMatrix temperatureData = 29;
102+
optional double temperature_polar = 30;
103+
optional double temperature_alpine = 31;
104+
optional double temperature_boreal = 32;
105+
optional double temperature_cool = 33;
106+
optional double temperature_warm = 34;
107+
optional double temperature_subtropical = 35;
105108

106109
// Data about generation:
107110
// introduced in v0.5.3
108111
// this is optional for backward compatibility reasons
109-
optional GenerationData generationData = 33;
112+
optional GenerationData generationData = 36;
110113

111-
optional DoubleMatrix lakemap = 34;
112-
optional DoubleMatrix rivermap = 35;
114+
optional DoubleMatrix lakemap = 37;
115+
optional DoubleMatrix rivermap = 38;
113116

114117
// Ice-caps
115-
optional DoubleMatrix icecap = 36;
118+
optional DoubleMatrix icecap = 39;
116119
}
117120

118121

worldengine/draw.py

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@
1111
### For draw_satellite ###
1212
NOISE_RANGE = 15 # a random value between -NOISE_RANGE and NOISE_RANGE will be added to the rgb of each pixel
1313

14-
# These are arbitrarily-chosen elevation cutoffs for 4 different height levels.
15-
# Some color modifiers will be applied at each level
16-
HIGH_MOUNTAIN_ELEV = 215
17-
MOUNTAIN_ELEV = 175
18-
HIGH_HILL_ELEV = 160
19-
HILL_ELEV = 145
20-
2114
# These are rgb color values which will be added to the noise, if the elevation is greater than the height specified
2215
# These are not cumulative
2316
HIGH_MOUNTAIN_NOISE_MODIFIER = (10, 6, 10)
@@ -279,30 +272,29 @@ def get_biome_color_based_on_elevation(world, elev, x, y, rng):
279272
## Generate some random noise to apply to this pixel
280273
# There is noise for each element of the rgb value
281274
# This noise will be further modified by the height of this tile
282-
283275
noise = rng.randint(-NOISE_RANGE, NOISE_RANGE, size=3) # draw three random numbers at once
284276

285-
####### Case 1 - elevation is very high ########
286-
if elev > HIGH_MOUNTAIN_ELEV:
287-
# Modify the noise to make the area slightly brighter to simulate snow-topped mountains.
288-
noise = add_colors(noise, HIGH_MOUNTAIN_NOISE_MODIFIER)
289-
# Average the biome's color with the MOUNTAIN_COLOR to tint the terrain
290-
biome_color = average_colors(biome_color, MOUNTAIN_COLOR)
291-
292-
####### Case 2 - elevation is high ########
293-
elif elev > MOUNTAIN_ELEV:
294-
# Modify the noise to make this tile slightly darker, especially draining the green
295-
noise = add_colors(noise, MOUNTAIN_NOISE_MODIFIER)
296-
# Average the biome's color with the MOUNTAIN_COLOR to tint the terrain
297-
biome_color = average_colors(biome_color, MOUNTAIN_COLOR)
298-
299-
####### Case 3 - elevation is somewhat high ########
300-
elif elev > HIGH_HILL_ELEV:
301-
noise = add_colors(noise, HIGH_HILL_NOISE_MODIFIER)
302-
303-
####### Case 4 - elevation is a little bit high ########
304-
elif elev > HILL_ELEV:
305-
noise = add_colors(noise, HILL_NOISE_MODIFIER)
277+
####### Case 1 - elevation is very high ########
278+
if world.is_high_mountain((x, y)):
279+
# Modify the noise to make the area slightly brighter to simulate snow-topped mountains.
280+
noise = add_colors(noise, HIGH_MOUNTAIN_NOISE_MODIFIER)
281+
# Average the biome's color with the MOUNTAIN_COLOR to tint the terrain
282+
biome_color = average_colors(biome_color, MOUNTAIN_COLOR)
283+
284+
####### Case 2 - elevation is high ########
285+
elif world.is_medium_mountain((x, y)):
286+
# Modify the noise to make this tile slightly darker, especially draining the green
287+
noise = add_colors(noise, MOUNTAIN_NOISE_MODIFIER)
288+
# Average the biome's color with the MOUNTAIN_COLOR to tint the terrain
289+
biome_color = average_colors(biome_color, MOUNTAIN_COLOR)
290+
291+
####### Case 3 - elevation is somewhat high ########
292+
elif world.is_low_mountain((x, y)):
293+
noise = add_colors(noise, HIGH_HILL_NOISE_MODIFIER)
294+
295+
####### Case 4 - elevation is a little bit high ########
296+
elif world.is_hill((x, y)):
297+
noise = add_colors(noise, HILL_NOISE_MODIFIER)
306298

307299
# There is also a minor base modifier to the pixel's rgb value based on height
308300
modification_amount = int(elev / BASE_ELEVATION_INTENSITY_MODIFIER)

worldengine/generation.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,17 @@ def initialize_ocean_and_thresholds(world, ocean_level=1.0):
125125
"""
126126
e = world.elevation['data']
127127
ocean = fill_ocean(e, ocean_level)
128-
hl = find_threshold_f(e, 0.10) # the highest 10% of all (!) land are declared hills
129-
ml = find_threshold_f(e, 0.03) # the highest 3% are declared mountains
128+
pl = find_threshold_f(e, 0.70, ocean=ocean) # the highest x% of land are declared plains
129+
hl = find_threshold_f(e, 0.35, ocean=ocean) # the highest x% are declared hills
130+
ml = find_threshold_f(e, 0.10, ocean=ocean) # the highest x% are declared low mountains
131+
mml = find_threshold_f(e, 0.06, ocean=ocean) # the highest x% are declared medium mountains
132+
hml = find_threshold_f(e, 0.02, ocean=ocean) # the highest x% are declared high mountains
130133
e_th = [('sea', ocean_level),
131-
('plain', hl),
132-
('hill', ml),
133-
('mountain', None)]
134+
('plain', pl),
135+
('hill', hl),
136+
('mountain', ml),
137+
('med_mountain', mml),
138+
('high_mountain', hml)]
134139
harmonize_ocean(ocean, e, ocean_level)
135140
world.set_ocean(ocean)
136141
world.set_elevation(e, e_th)

worldengine/hdf5_serialization.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ def save_world_to_hdf5(world, filename):
1919
elevation_ths_grp["sea"] = world.elevation['thresholds'][0][1]
2020
elevation_ths_grp["plain"] = world.elevation['thresholds'][1][1]
2121
elevation_ths_grp["hill"] = world.elevation['thresholds'][2][1]
22+
elevation_ths_grp["low_mountain"] = world.elevation['thresholds'][3][1]
23+
elevation_ths_grp["med_mountain"] = world.elevation['thresholds'][4][1]
24+
elevation_ths_grp["high_mountain"] = world.elevation['thresholds'][5][1]
2225
elevation_data = elevation_grp.create_dataset("data", (world.height, world.width), dtype=numpy.float)
2326
elevation_data.write_direct(world.elevation['data'])
2427

@@ -139,7 +142,9 @@ def load_world_to_hdf5(filename):
139142
e_th = [('sea', f['elevation/thresholds/sea'].value),
140143
('plain', f['elevation/thresholds/plain'].value),
141144
('hill', f['elevation/thresholds/hill'].value),
142-
('mountain', None)]
145+
('mountain', f['elevation/thresholds/low_mountain'].value),
146+
('med_mountain', f['elevation/thresholds/med_mountain'].value),
147+
('high_mountain', f['elevation/thresholds/high_mountain'].value)]
143148
w.set_elevation(e, e_th)
144149

145150
# Plates

0 commit comments

Comments
 (0)