Skip to content

Commit 0ca78de

Browse files
committed
Fixes to make the ocean_level-variable work properly.
1 parent ec48574 commit 0ca78de

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

worldengine/cli/main.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
import numpy
55
import worldengine.generation as geo
6+
from worldengine.simulations.basic import find_threshold_f
67
from worldengine.common import array_to_matrix, set_verbose, print_verbose
78
from worldengine.draw import draw_ancientmap_on_file, draw_biome_on_file, draw_ocean_on_file, \
89
draw_precipitation_on_file, draw_grayscale_heightmap_on_file, draw_simple_elevation_on_file, \
@@ -97,7 +98,7 @@ def draw_icecaps_map(world, filename):
9798
print("+ icecap map generated in '%s'" % filename)
9899

99100
def generate_plates(seed, world_name, output_dir, width, height,
100-
num_plates=10):
101+
ocean_level, num_plates=10):
101102
"""
102103
Eventually this method should be invoked when generation is called at
103104
asked to stop at step "plates", it should not be a different operation
@@ -110,6 +111,7 @@ def generate_plates(seed, world_name, output_dir, width, height,
110111
:return:
111112
"""
112113
elevation, plates = generate_plates_simulation(seed, width, height,
114+
ocean_level=ocean_level,
113115
num_plates=num_plates)
114116

115117
world = World(world_name, width, height, seed, num_plates, -1.0, "plates")
@@ -118,11 +120,13 @@ def generate_plates(seed, world_name, output_dir, width, height,
118120

119121
# Generate images
120122
filename = '%s/plates_%s.png' % (output_dir, world_name)
121-
draw_simple_elevation_on_file(world, filename, None)
123+
sea_level = find_threshold_f(world.elevation['data'], 1.0 - ocean_level,
124+
ocean=None, max=1.0, mindist=0.000005)
125+
draw_simple_elevation_on_file(world, filename, sea_level)
122126
print("+ plates image generated in '%s'" % filename)
123127
geo.center_land(world)
124128
filename = '%s/centered_plates_%s.png' % (output_dir, world_name)
125-
draw_simple_elevation_on_file(world, filename, None)
129+
draw_simple_elevation_on_file(world, filename, sea_level)
126130
print("+ centered plates image generated in '%s'" % filename)
127131

128132

@@ -295,7 +299,7 @@ def main():
295299
g_generate.add_argument('--ocean_level', dest='ocean_level', type=float,
296300
help='amount of surface covered by ocean " +'
297301
'[default = %(default)s]',
298-
metavar="N", default=1.0)
302+
metavar="N", default=0.65)
299303
g_generate.add_argument('--temps', dest='temps',
300304
help="Provide alternate ranges for temperatures. " +
301305
"If not provided, the default values will be used. \n" +
@@ -557,7 +561,8 @@ def main():
557561
print('starting (it could take a few minutes) ...')
558562

559563
generate_plates(seed, world_name, args.output_dir, args.width,
560-
args.height, num_plates=args.number_of_plates)
564+
args.height, args.ocean_level,
565+
num_plates=args.number_of_plates)
561566

562567
elif operation == 'ancient_map':
563568
print('') # empty line

worldengine/generation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def initialize_ocean_and_thresholds(world, ocean_level=0.65):
129129

130130
#Calculate the height of the ocean relative to the geometry
131131
ocean_maxlevel = find_threshold_f(e, 1.0 - ocean_level,
132-
ocean=None, max=1.0, mindist=0.00001)
132+
ocean=None, max=100.0, mindist=0.00001)
133133
ocean = fill_ocean(e, ocean_maxlevel)
134134

135135
hl = find_threshold_f(e, 0.10) # the highest 10% of all (!) land are declared hills

worldengine/plates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def world_gen(name, width, height, seed, temps=[.874, .765, .594, .439, .366, .1
8080
start_time = time.time()
8181
if fade_borders:
8282
place_oceans_at_map_borders(world)
83-
initialize_ocean_and_thresholds(world)
83+
initialize_ocean_and_thresholds(world, ocean_level)
8484
if verbose:
8585
elapsed_time = time.time() - start_time
8686
print("...plates.world_gen: oceans initialized. Elapsed time " +

0 commit comments

Comments
 (0)