-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More Mountain Levels #188
base: master
Are you sure you want to change the base?
More Mountain Levels #188
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
|
@@ -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 was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
# There is also a minor base modifier to the pixel's rgb value based on height | ||
modification_amount = int(elev / BASE_ELEVATION_INTENSITY_MODIFIER) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,12 +105,20 @@ 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 | ||
|
||
# values chosen to emulate the exponential behavior seen here: | ||
# http://www.ngdc.noaa.gov/mgg/global/etopo1_surface_histogram.html | ||
pl = find_threshold_f(e, 0.80, ocean=ocean) # the highest x% of land are declared plains; save some for beaches (?) | ||
hl = find_threshold_f(e, 0.40, ocean=ocean) # the highest x% are declared hills | ||
ml = find_threshold_f(e, 0.20, ocean=ocean) # the highest x% are declared low mountains | ||
mml = find_threshold_f(e, 0.10, ocean=ocean) # the highest x% are declared medium mountains | ||
hml = find_threshold_f(e, 0.05, ocean=ocean) # the highest x% are declared high mountains | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed the values a bit, created new plots and want to collect all the important points in a single post: The new values declare the following values, in relation to total land (in the code the values are relative to non-submerged land): So the former "hills" roughly correspond to "medium mountains" now. Thus the changes to river-, temperature- and ancient map-generation. The choices in there made sense, but the hill-level was very high. The following two plots show the old and new height-levels: The plains are set to 80% (of non-submerged land) since due to possible depressions in the land 100% would end up below sea-level. 80% leaves a little wiggle-room. If anybody has more accurate data, please point me to it (other criticism is welcome, too). For now the values seem reasonable and the results of world-generation look good to me. |
||
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) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it problematic to add the new variables in the "middle" instead of the end?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, that breaks compatibility but in this case I would say it is intended