Skip to content

Commit

Permalink
Fixes to make the ocean_level-variable work properly.
Browse files Browse the repository at this point in the history
  • Loading branch information
tcld committed Nov 18, 2015
1 parent 61b42b4 commit 3249f8c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
15 changes: 10 additions & 5 deletions worldengine/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import numpy
import worldengine.generation as geo
from worldengine.simulations.basic import find_threshold_f
from worldengine.common import set_verbose, print_verbose
from worldengine.draw import draw_ancientmap_on_file, draw_biome_on_file, draw_ocean_on_file, \
draw_precipitation_on_file, draw_grayscale_heightmap_on_file, draw_simple_elevation_on_file, \
Expand Down Expand Up @@ -97,7 +98,7 @@ def draw_icecaps_map(world, filename):
print("+ icecap map generated in '%s'" % filename)

def generate_plates(seed, world_name, output_dir, width, height,
num_plates=10):
ocean_level, num_plates=10):
"""
Eventually this method should be invoked when generation is called at
asked to stop at step "plates", it should not be a different operation
Expand All @@ -110,6 +111,7 @@ def generate_plates(seed, world_name, output_dir, width, height,
:return:
"""
elevation, plates = generate_plates_simulation(seed, width, height,
ocean_level=ocean_level,
num_plates=num_plates)

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

# Generate images
filename = '%s/plates_%s.png' % (output_dir, world_name)
draw_simple_elevation_on_file(world, filename, None)
sea_level = find_threshold_f(world.elevation['data'], 1.0 - ocean_level,
ocean=None, max=1.0, mindist=0.000005)
draw_simple_elevation_on_file(world, filename, sea_level)
print("+ plates image generated in '%s'" % filename)
geo.center_land(world)
filename = '%s/centered_plates_%s.png' % (output_dir, world_name)
draw_simple_elevation_on_file(world, filename, None)
draw_simple_elevation_on_file(world, filename, sea_level)
print("+ centered plates image generated in '%s'" % filename)


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

generate_plates(seed, world_name, args.output_dir, args.width,
args.height, num_plates=args.number_of_plates)
args.height, args.ocean_level,
num_plates=args.number_of_plates)

elif operation == 'ancient_map':
print('') # empty line
Expand Down
2 changes: 1 addition & 1 deletion worldengine/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def initialize_ocean_and_thresholds(world, ocean_level=0.65):

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

hl = find_threshold_f(e, 0.10) # the highest 10% of all (!) land are declared hills
Expand Down
2 changes: 1 addition & 1 deletion worldengine/plates.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def world_gen(name, width, height, seed, temps=[.874, .765, .594, .439, .366, .1
start_time = time.time()
if fade_borders:
place_oceans_at_map_borders(world)
initialize_ocean_and_thresholds(world)
initialize_ocean_and_thresholds(world, ocean_level)
if verbose:
elapsed_time = time.time() - start_time
print("...plates.world_gen: oceans initialized. Elapsed time " +
Expand Down

0 comments on commit 3249f8c

Please sign in to comment.