def generate_world(w, step): if isinstance(step, str): step = Step.get_by_name(step) if not step.include_precipitations: return w # Prepare sufficient seeds for the different steps of the generation rng = numpy.random.RandomState(w.seed) # create a fresh RNG in case the global RNG is compromised (i.e. has been queried an indefinite amount of times before generate_world() was called) sub_seeds = rng.randint(0, numpy.iinfo(numpy.int32).max, size=100) # choose lowest common denominator (32 bit Windows numpy cannot handle a larger value) seed_dict = { 'PrecipitationSimulation': sub_seeds[ 0], # after 0.19.0 do not ever switch out the seeds here to maximize seed-compatibility 'ErosionSimulation': sub_seeds[ 1], 'WatermapSimulation': sub_seeds[ 2], 'IrrigationSimulation': sub_seeds[ 3], 'TemperatureSimulation': sub_seeds[ 4], 'HumiditySimulation': sub_seeds[ 5], 'PermeabilitySimulation': sub_seeds[ 6], 'BiomeSimulation': sub_seeds[ 7], 'IcecapSimulation': sub_seeds[ 8], '': sub_seeds[99] } TemperatureSimulation().execute(w, seed_dict['TemperatureSimulation']) # Precipitation with thresholds PrecipitationSimulation().execute(w, seed_dict['PrecipitationSimulation']) if not step.include_erosion: return w ErosionSimulation().execute(w, seed_dict['ErosionSimulation']) # seed not currently used if get_verbose(): print("...erosion calculated") WatermapSimulation().execute(w, seed_dict['WatermapSimulation']) # seed not currently used # FIXME: create setters IrrigationSimulation().execute(w, seed_dict['IrrigationSimulation']) # seed not currently used HumiditySimulation().execute(w, seed_dict['HumiditySimulation']) # seed not currently used PermeabilitySimulation().execute(w, seed_dict['PermeabilitySimulation']) cm, biome_cm = BiomeSimulation().execute(w, seed_dict['BiomeSimulation']) # seed not currently used for cl in cm.keys(): count = cm[cl] if get_verbose(): print("%s = %i" % (str(cl), count)) if get_verbose(): print('') # empty line print('Biome obtained:') for cl in biome_cm.keys(): count = biome_cm[cl] if get_verbose(): print(" %30s = %7i" % (str(cl), count)) IcecapSimulation().execute(w, seed_dict['IcecapSimulation']) # makes use of temperature-map return w
def set_world(self, world): self.world = world self.canvas = MapCanvas(self.label, self.world.width, self.world.height) self._on_bw_view() self.saveproto_action.setEnabled(world is not None) self.bw_view.setEnabled(world is not None) self.plates_view.setEnabled(world is not None) self.plates_bw_view.setEnabled(world is not None) self.watermap_view.setEnabled(world is not None and WatermapView().is_applicable(world)) self.precipitations_view.setEnabled( world is not None and PrecipitationsView().is_applicable(world)) self.land_and_ocean_view.setEnabled(world is not None) self.precipitations_action.setEnabled(world is not None and (not world.has_precipitations())) self.watermap_action.setEnabled( world is not None and WatermapSimulation().is_applicable(world)) self.irrigation_action.setEnabled( world is not None and IrrigationSimulation().is_applicable(world)) self.humidity_action.setEnabled( world is not None and HumiditySimulation().is_applicable(world)) self.temperature_action.setEnabled( world is not None and TemperatureSimulation().is_applicable(world)) self.permeability_action.setEnabled( world is not None and PermeabilitySimulation().is_applicable(world)) self.biome_action.setEnabled( world is not None and BiomeSimulation().is_applicable(world)) self.erosion_action.setEnabled( world is not None and ErosionSimulation().is_applicable(world))
def _on_biome(self): dialog = OperationDialog( self, self.world, SimulationOp("Simulating biome", BiomeSimulation())) ok = dialog.exec_() if ok: # just to refresh things to enable self.set_world(self.world)
def generate_world(w, step): if isinstance(step, str): step = Step.get_by_name(step) seed = w.seed if not step.include_precipitations: return w # Precipitation with thresholds PrecipitationSimulation().execute(w, seed) if not step.include_erosion: return w ErosionSimulation().execute(w, seed) if get_verbose(): print("...erosion calculated") WatermapSimulation().execute(w, seed) # FIXME: create setters IrrigationSimulation().execute(w, seed) TemperatureSimulation().execute(w, seed) HumiditySimulation().execute(w, seed) PermeabilitySimulation().execute(w, seed) cm, biome_cm = BiomeSimulation().execute(w, seed) for cl in cm.keys(): count = cm[cl] if get_verbose(): print("%s = %i" % (str(cl), count)) if get_verbose(): print('') # empty line print('Biome obtained:') for cl in biome_cm.keys(): count = biome_cm[cl] if get_verbose(): print(" %30s = %7i" % (str(cl), count)) return w
def generate_world(w, step): if isinstance(step, str): step = Step.get_by_name(step) seed = w.seed if not step.include_precipitations: return w # Precipitation with thresholds PrecipitationSimulation().execute(w, seed) if not step.include_erosion: return w ErosionSimulation().execute(w, seed) if get_verbose(): print("...erosion calculated") WatermapSimulation().execute(w, seed) # FIXME: create setters IrrigationSimulation().execute(w, seed) HumiditySimulation().execute(w, seed) TemperatureSimulation().execute(w, seed) PermeabilitySimulation().execute(w, seed) cm, biome_cm = BiomeSimulation().execute(w, seed) for cl in cm.keys(): count = cm[cl] if get_verbose(): print("%s = %i" % (str(cl), count)) if get_verbose(): print('') # empty line print('Biome obtained:') for cl in biome_cm.keys(): count = biome_cm[cl] if get_verbose(): print(" %30s = %7i" % (str(cl), count)) return w
def test_locate_biomes(self): w = World.open_protobuf("%s/seed_28070.world" % self.tests_data_dir) cm, biome_cm = BiomeSimulation().execute(w, 28070)
def generate_world(w, step): if isinstance(step, str): step = Step.get_by_name(step) if not step.include_precipitations: return w # Prepare sufficient seeds for the different steps of the generation rng = numpy.random.RandomState( w.seed ) # create a fresh RNG in case the global RNG is compromised (i.e. has been queried an indefinite amount of times before generate_world() was called) sub_seeds = rng.randint( 0, numpy.iinfo(numpy.int32).max, size=100 ) # choose lowest common denominator (32 bit Windows numpy cannot handle a larger value) seed_dict = { 'PrecipitationSimulation': sub_seeds[ 0], # after 0.19.0 do not ever switch out the seeds here to maximize seed-compatibility 'ErosionSimulation': sub_seeds[1], 'WatermapSimulation': sub_seeds[2], 'IrrigationSimulation': sub_seeds[3], 'TemperatureSimulation': sub_seeds[4], 'HumiditySimulation': sub_seeds[5], 'PermeabilitySimulation': sub_seeds[6], 'BiomeSimulation': sub_seeds[7], 'IcecapSimulation': sub_seeds[8], '': sub_seeds[99] } TemperatureSimulation().execute(w, seed_dict['TemperatureSimulation']) # Precipitation with thresholds PrecipitationSimulation().execute(w, seed_dict['PrecipitationSimulation']) if not step.include_erosion: return w ErosionSimulation().execute( w, seed_dict['ErosionSimulation']) # seed not currently used if get_verbose(): print("...erosion calculated") WatermapSimulation().execute( w, seed_dict['WatermapSimulation']) # seed not currently used # FIXME: create setters IrrigationSimulation().execute( w, seed_dict['IrrigationSimulation']) # seed not currently used HumiditySimulation().execute( w, seed_dict['HumiditySimulation']) # seed not currently used PermeabilitySimulation().execute(w, seed_dict['PermeabilitySimulation']) cm, biome_cm = BiomeSimulation().execute( w, seed_dict['BiomeSimulation']) # seed not currently used for cl in cm.keys(): count = cm[cl] if get_verbose(): print("%s = %i" % (str(cl), count)) if get_verbose(): print('') # empty line print('Biome obtained:') for cl in biome_cm.keys(): count = biome_cm[cl] if get_verbose(): print(" %30s = %7i" % (str(cl), count)) IcecapSimulation().execute( w, seed_dict['IcecapSimulation']) # makes use of temperature-map return w