55import pickle
66import random
77import worldengine .generation as geo
8+ from worldengine .simulations .basic import find_threshold_f
89from worldengine .common import array_to_matrix , set_verbose , print_verbose
910from worldengine .draw import draw_ancientmap_on_file , draw_biome_on_file , draw_ocean_on_file , \
1011 draw_precipitation_on_file , draw_grayscale_heightmap_on_file , draw_simple_elevation_on_file , \
@@ -80,7 +81,7 @@ def generate_rivers_map(world, filename):
8081
8182
8283def generate_plates (seed , world_name , output_dir , width , height ,
83- num_plates = 10 ):
84+ ocean_level , num_plates = 10 ):
8485 """
8586 Eventually this method should be invoked when generation is called at
8687 asked to stop at step "plates", it should not be a different operation
@@ -93,6 +94,7 @@ def generate_plates(seed, world_name, output_dir, width, height,
9394 :return:
9495 """
9596 elevation , plates = generate_plates_simulation (seed , width , height ,
97+ ocean_level = ocean_level ,
9698 num_plates = num_plates )
9799
98100 world = World (world_name , width , height , seed , num_plates , - 1.0 , "plates" )
@@ -101,8 +103,9 @@ def generate_plates(seed, world_name, output_dir, width, height,
101103
102104 # Generate images
103105 filename = '%s/plates_%s.png' % (output_dir , world_name )
104- # TODO calculate appropriate sea_level
105- sea_level = 1.0
106+ sea_level = find_threshold_f (world .elevation ['data' ], 1.0 - ocean_level ,
107+ ocean = None , max = 1.0 , mindist = 0.000005 )
108+
106109 draw_simple_elevation_on_file (world .elevation ['data' ], filename , width ,
107110 height , sea_level )
108111 print ("+ plates image generated in '%s'" % filename )
@@ -300,7 +303,7 @@ def main():
300303 g_generate .add_argument ('--ocean_level' , dest = 'ocean_level' , type = float ,
301304 help = 'amount of surface covered by ocean " +'
302305 '[default = %(default)s]' ,
303- metavar = "N" , default = 1.0 )
306+ metavar = "N" , default = 0.65 )
304307
305308 # -----------------------------------------------------
306309 g_ancient_map = parser .add_argument_group (
@@ -463,7 +466,8 @@ def main():
463466 print ('starting (it could take a few minutes) ...' )
464467
465468 generate_plates (seed , world_name , args .output_dir , args .width ,
466- args .height , num_plates = args .number_of_plates )
469+ args .height , args .ocean_level ,
470+ num_plates = args .number_of_plates )
467471
468472 elif operation == 'ancient_map' :
469473 print ('' ) # empty line
0 commit comments