Skip to content

Commit 87aef2a

Browse files
committed
Added some mountain levels and made satellite-map mountain-levels dynamic.
Updated World.proto and World_pb2.py.
1 parent c773405 commit 87aef2a

File tree

7 files changed

+203
-179
lines changed

7 files changed

+203
-179
lines changed

generate_protobuf_stubs.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.

worldengine/World.proto

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
syntax = "proto2";
12
package World;
23

34
message World {
@@ -61,55 +62,58 @@ message World {
6162
required double heightMapTh_sea = 7;
6263
required double heightMapTh_plain = 8;
6364
required double heightMapTh_hill = 9;
65+
required double heightMapTh_low_mountain = 10;
66+
required double heightMapTh_med_mountain = 11;
67+
required double heightMapTh_high_mountain = 12;
6468

6569
// Plates
66-
required IntegerMatrix plates = 10;
70+
required IntegerMatrix plates = 13;
6771

6872
// Ocean
69-
required BooleanMatrix ocean = 11;
70-
required DoubleMatrix sea_depth = 12;
73+
required BooleanMatrix ocean = 14;
74+
required DoubleMatrix sea_depth = 15;
7175

7276
// Biome
73-
optional IntegerMatrix biome = 13;
77+
optional IntegerMatrix biome = 16;
7478

7579
// Humidity
76-
optional DoubleMatrixWithQuantiles humidity = 14;
80+
optional DoubleMatrixWithQuantiles humidity = 17;
7781

7882
// Irrigation
79-
optional DoubleMatrix irrigation = 15;
83+
optional DoubleMatrix irrigation = 18;
8084

8185
// Permeability
82-
optional DoubleMatrix permeabilityData = 16;
83-
optional double permeability_low = 17;
84-
optional double permeability_med = 18;
86+
optional DoubleMatrix permeabilityData = 19;
87+
optional double permeability_low = 20;
88+
optional double permeability_med = 21;
8589

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

9296
// Precipitation
93-
optional DoubleMatrix precipitationData = 23;
94-
optional double precipitation_low = 24;
95-
optional double precipitation_med = 25;
97+
optional DoubleMatrix precipitationData = 26;
98+
optional double precipitation_low = 27;
99+
optional double precipitation_med = 28;
96100

97101
// 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;
102+
optional DoubleMatrix temperatureData = 29;
103+
optional double temperature_polar = 30;
104+
optional double temperature_alpine = 31;
105+
optional double temperature_boreal = 32;
106+
optional double temperature_cool = 33;
107+
optional double temperature_warm = 34;
108+
optional double temperature_subtropical = 35;
105109

106110
// Data about generation:
107111
// introduced in v0.5.3
108112
// this is optional for backward compatibility reasons
109-
optional GenerationData generationData = 33;
113+
optional GenerationData generationData = 36;
110114

111-
optional DoubleMatrix lakemap = 34;
112-
optional DoubleMatrix rivermap = 35;
115+
optional DoubleMatrix lakemap = 37;
116+
optional DoubleMatrix rivermap = 38;
113117

114118
}
115119

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
@@ -124,12 +124,17 @@ def initialize_ocean_and_thresholds(world, ocean_level=1.0):
124124
"""
125125
e = world.elevation['data']
126126
ocean = fill_ocean(e, ocean_level)
127-
hl = find_threshold_f(e, 0.10) # the highest 10% of all (!) land are declared hills
128-
ml = find_threshold_f(e, 0.03) # the highest 3% are declared mountains
127+
pl = find_threshold_f(e, 0.70, ocean=ocean) # the highest 70% of land are declared plains
128+
hl = find_threshold_f(e, 0.35, ocean=ocean) # the highest 35% are declared hills
129+
ml = find_threshold_f(e, 0.10, ocean=ocean) # the highest 10% are declared low mountains
130+
mml = find_threshold_f(e, 0.06, ocean=ocean) # the highest 10% are declared medium mountains
131+
hml = find_threshold_f(e, 0.02, ocean=ocean) # the highest 10% are declared high mountains
129132
e_th = [('sea', ocean_level),
130-
('plain', hl),
131-
('hill', ml),
132-
('mountain', None)]
133+
('plain', pl),
134+
('hill', hl),
135+
('mountain', ml),
136+
('med_mountain', mml),
137+
('high_mountain', hml)]
133138
harmonize_ocean(ocean, e, ocean_level)
134139
world.set_ocean(ocean)
135140
world.set_elevation(e, e_th)

0 commit comments

Comments
 (0)