Skip to content

Commit

Permalink
Added some mountain levels and made satellite-map mountain-levels dyn…
Browse files Browse the repository at this point in the history
…amic.

Updated World.proto and World_pb2.py.
  • Loading branch information
tcld committed Nov 18, 2015
1 parent 3e8030e commit 5b9b83b
Show file tree
Hide file tree
Showing 7 changed files with 200 additions and 180 deletions.
65 changes: 34 additions & 31 deletions worldengine/World.proto
Original file line number Diff line number Diff line change
Expand Up @@ -57,62 +57,65 @@ message World {
required int32 height = 5;

// Elevation
required DoubleMatrix heightMapData = 6;
required double heightMapTh_sea = 7;
required double heightMapTh_plain = 8;
required double heightMapTh_hill = 9;
required DoubleMatrix heightMapData = 6;
required double heightMapTh_sea = 7;
required double heightMapTh_plain = 8;
required double heightMapTh_hill = 9;
required double heightMapTh_low_mountain = 10;
required double heightMapTh_med_mountain = 11;
required double heightMapTh_high_mountain = 12;

// Plates
required IntegerMatrix plates = 10;
required IntegerMatrix plates = 13;

// Ocean
required BooleanMatrix ocean = 11;
required DoubleMatrix sea_depth = 12;
required BooleanMatrix ocean = 14;
required DoubleMatrix sea_depth = 15;

// Biome
optional IntegerMatrix biome = 13;
optional IntegerMatrix biome = 16;

// Humidity
optional DoubleMatrixWithQuantiles humidity = 14;
optional DoubleMatrixWithQuantiles humidity = 17;

// Irrigation
optional DoubleMatrix irrigation = 15;
optional DoubleMatrix irrigation = 18;

// Permeability
optional DoubleMatrix permeabilityData = 16;
optional double permeability_low = 17;
optional double permeability_med = 18;
optional DoubleMatrix permeabilityData = 19;
optional double permeability_low = 20;
optional double permeability_med = 21;

// Watermap
optional DoubleMatrix watermapData = 19;
optional double watermap_creek = 20;
optional double watermap_river = 21;
optional double watermap_mainriver = 22;
optional DoubleMatrix watermapData = 22;
optional double watermap_creek = 23;
optional double watermap_river = 24;
optional double watermap_mainriver = 25;

// Precipitation
optional DoubleMatrix precipitationData = 23;
optional double precipitation_low = 24;
optional double precipitation_med = 25;
optional DoubleMatrix precipitationData = 26;
optional double precipitation_low = 27;
optional double precipitation_med = 28;

// Temperature
optional DoubleMatrix temperatureData = 26;
optional double temperature_polar = 27;
optional double temperature_alpine = 28;
optional double temperature_boreal = 29;
optional double temperature_cool = 30;
optional double temperature_warm = 31;
optional double temperature_subtropical = 32;
optional DoubleMatrix temperatureData = 29;
optional double temperature_polar = 30;
optional double temperature_alpine = 31;
optional double temperature_boreal = 32;
optional double temperature_cool = 33;
optional double temperature_warm = 34;
optional double temperature_subtropical = 35;

// Data about generation:
// introduced in v0.5.3
// this is optional for backward compatibility reasons
optional GenerationData generationData = 33;
optional GenerationData generationData = 36;

optional DoubleMatrix lakemap = 34;
optional DoubleMatrix rivermap = 35;
optional DoubleMatrix lakemap = 37;
optional DoubleMatrix rivermap = 38;

// Ice-caps
optional DoubleMatrix icecap = 36;
optional DoubleMatrix icecap = 39;
}


50 changes: 21 additions & 29 deletions worldengine/draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@
### For draw_satellite ###
NOISE_RANGE = 15 # a random value between -NOISE_RANGE and NOISE_RANGE will be added to the rgb of each pixel

# These are arbitrarily-chosen elevation cutoffs for 4 different height levels.
# Some color modifiers will be applied at each level
HIGH_MOUNTAIN_ELEV = 215
MOUNTAIN_ELEV = 175
HIGH_HILL_ELEV = 160
HILL_ELEV = 145

# These are rgb color values which will be added to the noise, if the elevation is greater than the height specified
# These are not cumulative
HIGH_MOUNTAIN_NOISE_MODIFIER = (10, 6, 10)
Expand Down Expand Up @@ -279,30 +272,29 @@ def get_biome_color_based_on_elevation(world, elev, x, y, rng):
## Generate some random noise to apply to this pixel
# There is noise for each element of the rgb value
# This noise will be further modified by the height of this tile

noise = rng.randint(-NOISE_RANGE, NOISE_RANGE, size=3) # draw three random numbers at once

####### Case 1 - elevation is very high ########
if elev > HIGH_MOUNTAIN_ELEV:
# Modify the noise to make the area slightly brighter to simulate snow-topped mountains.
noise = add_colors(noise, HIGH_MOUNTAIN_NOISE_MODIFIER)
# Average the biome's color with the MOUNTAIN_COLOR to tint the terrain
biome_color = average_colors(biome_color, MOUNTAIN_COLOR)

####### Case 2 - elevation is high ########
elif elev > MOUNTAIN_ELEV:
# Modify the noise to make this tile slightly darker, especially draining the green
noise = add_colors(noise, MOUNTAIN_NOISE_MODIFIER)
# Average the biome's color with the MOUNTAIN_COLOR to tint the terrain
biome_color = average_colors(biome_color, MOUNTAIN_COLOR)

####### Case 3 - elevation is somewhat high ########
elif elev > HIGH_HILL_ELEV:
noise = add_colors(noise, HIGH_HILL_NOISE_MODIFIER)

####### Case 4 - elevation is a little bit high ########
elif elev > HILL_ELEV:
noise = add_colors(noise, HILL_NOISE_MODIFIER)
####### Case 1 - elevation is very high ########
if world.is_high_mountain((x, y)):
# Modify the noise to make the area slightly brighter to simulate snow-topped mountains.
noise = add_colors(noise, HIGH_MOUNTAIN_NOISE_MODIFIER)
# Average the biome's color with the MOUNTAIN_COLOR to tint the terrain
biome_color = average_colors(biome_color, MOUNTAIN_COLOR)

####### Case 2 - elevation is high ########
elif world.is_medium_mountain((x, y)):
# Modify the noise to make this tile slightly darker, especially draining the green
noise = add_colors(noise, MOUNTAIN_NOISE_MODIFIER)
# Average the biome's color with the MOUNTAIN_COLOR to tint the terrain
biome_color = average_colors(biome_color, MOUNTAIN_COLOR)

####### Case 3 - elevation is somewhat high ########
elif world.is_low_mountain((x, y)):
noise = add_colors(noise, HIGH_HILL_NOISE_MODIFIER)

####### Case 4 - elevation is a little bit high ########
elif world.is_hill((x, y)):
noise = add_colors(noise, HILL_NOISE_MODIFIER)

# There is also a minor base modifier to the pixel's rgb value based on height
modification_amount = int(elev / BASE_ELEVATION_INTENSITY_MODIFIER)
Expand Down
15 changes: 10 additions & 5 deletions worldengine/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,17 @@ def initialize_ocean_and_thresholds(world, ocean_level=1.0):
"""
e = world.elevation['data']
ocean = fill_ocean(e, ocean_level)
hl = find_threshold_f(e, 0.10) # the highest 10% of all (!) land are declared hills
ml = find_threshold_f(e, 0.03) # the highest 3% are declared mountains
pl = find_threshold_f(e, 0.70, ocean=ocean) # the highest x% of land are declared plains
hl = find_threshold_f(e, 0.35, ocean=ocean) # the highest x% are declared hills
ml = find_threshold_f(e, 0.10, ocean=ocean) # the highest x% are declared low mountains
mml = find_threshold_f(e, 0.06, ocean=ocean) # the highest x% are declared medium mountains
hml = find_threshold_f(e, 0.02, ocean=ocean) # the highest x% are declared high mountains
e_th = [('sea', ocean_level),
('plain', hl),
('hill', ml),
('mountain', None)]
('plain', pl),
('hill', hl),
('mountain', ml),
('med_mountain', mml),
('high_mountain', hml)]
harmonize_ocean(ocean, e, ocean_level)
world.set_ocean(ocean)
world.set_elevation(e, e_th)
Expand Down
7 changes: 6 additions & 1 deletion worldengine/hdf5_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def save_world_to_hdf5(world, filename):
elevation_ths_grp["sea"] = world.elevation['thresholds'][0][1]
elevation_ths_grp["plain"] = world.elevation['thresholds'][1][1]
elevation_ths_grp["hill"] = world.elevation['thresholds'][2][1]
elevation_ths_grp["low_mountain"] = world.elevation['thresholds'][3][1]
elevation_ths_grp["med_mountain"] = world.elevation['thresholds'][4][1]
elevation_ths_grp["high_mountain"] = world.elevation['thresholds'][5][1]
elevation_data = elevation_grp.create_dataset("data", (world.height, world.width), dtype=numpy.float)
elevation_data.write_direct(world.elevation['data'])

Expand Down Expand Up @@ -137,7 +140,9 @@ def load_world_to_hdf5(filename):
e_th = [('sea', f['elevation/thresholds/sea'].value),
('plain', f['elevation/thresholds/plain'].value),
('hill', f['elevation/thresholds/hill'].value),
('mountain', None)]
('mountain', f['elevation/thresholds/low_mountain'].value),
('med_mountain', f['elevation/thresholds/med_mountain'].value),
('high_mountain', f['elevation/thresholds/high_mountain'].value)]
w.set_elevation(e, e_th)

# Plates
Expand Down
Loading

0 comments on commit 5b9b83b

Please sign in to comment.