def __init__(self, config, world): self.groups = [] self._config = {} self.load_config(config) self._world = World.open_protobuf(world) self._turn = 0 self._global_events = self._config["Tribe"]["General"]["Global-events"]
def test_center_land(self): w = World.open_protobuf("%s/seed_28070.world" % self.tests_data_dir) # We want to have less land than before at the borders el_before = TestGeneration._mean_elevation_at_borders(w) center_land(w) el_after = TestGeneration._mean_elevation_at_borders(w) self.assertTrue(el_after <= el_before)
def load_world(world_filename): pb = __seems_protobuf_worldfile__(world_filename) if pb: try: return World.open_protobuf(world_filename) except Exception: raise Exception("Unable to load the worldfile as protobuf file") else: raise Exception("The given worldfile does not seem to be a protobuf file")
def load_world(world_filename): pb = __seems_protobuf_worldfile__(world_filename) if pb: try: return World.open_protobuf(world_filename) except Exception: raise Exception("Unable to load the worldfile as protobuf file") else: raise Exception( "The given worldfile does not seem to be a protobuf file")
def load_world(world_filename): pb = __seems_protobuf_worldfile__(world_filename) pi = __seems_pickle_file__(world_filename) if pb and pi: print("we cannot distinguish if the file is a pickle or a protobuf worldfile. " + "Trying to load first as protobuf then as pickle file") try: return World.open_protobuf(world_filename) except Exception: try: return World.from_pickle_file(world_filename) except Exception: raise Exception("Unable to load the worldfile neither as protobuf or pickle file") elif pb: return World.open_protobuf(world_filename) elif pi: return World.from_pickle_file(world_filename) else: raise Exception("The given worldfile does not seem a pickle or a protobuf file")
def load_world(world_filename): pb = __seems_protobuf_worldfile__(world_filename) pi = __seems_pickle_file__(world_filename) if pb and pi: print("we cannot distinguish if the file is a pickle or a protobuf " "world file. Trying to load first as protobuf then as pickle " "file") try: return World.open_protobuf(world_filename) except Exception: try: return World.from_pickle_file(world_filename) except Exception: raise Exception("Unable to load the worldfile neither as protobuf or pickle file") elif pb: return World.open_protobuf(world_filename) elif pi: return World.from_pickle_file(world_filename) else: raise Exception("The given worldfile does not seem a pickle or a protobuf file")
def test_draw_biome(self): w = World.open_protobuf("%s/seed_28070.world" % self.tests_data_dir) target = PixelCollector(w.width, w.height) draw_biome(w, target) self._assert_img_equal("biome_28070", target)
def test_draw_simple_elevation(self): w = World.open_protobuf("%s/seed_28070.world" % self.tests_data_dir) data = w.elevation['data'] target = PixelCollector(w.width, w.height) draw_simple_elevation(data, w.width, w.height, w.sea_level(), target) self._assert_img_equal("simple_elevation_28070", target)
def test_draw_elevation_no_shadow(self): w = World.open_protobuf("%s/seed_28070.world" % self.tests_data_dir) data = w.elevation['data'] target = PixelCollector(w.width, w.height) draw_elevation(w, False, target) self._assert_img_equal("elevation_28070_no_shadow", target)
def setUp(self): super(TestDrawingFunctions, self).setUp() self.w = World.open_protobuf("%s/seed_28070.world" % self.tests_data_dir)
def test_draw_simple_elevation(self): w = World.open_protobuf("%s/seed_28070.world" % self.tests_data_dir) target = PNGWriter.rgba_from_dimensions(w.width, w.height) draw_simple_elevation(w, w.sea_level(), target) self._assert_img_equal("simple_elevation_28070", target)
def test_draw_satellite(self): w = World.open_protobuf("%s/seed_28070.world" % self.tests_data_dir) target = PNGWriter.rgba_from_dimensions(w.width, w.height) draw_satellite(w, target) self._assert_img_equal("satellite_28070", target)
def test_draw_scatter_plot(self): w = World.open_protobuf("%s/seed_28070.world" % self.tests_data_dir) target = PNGWriter.rgba_from_dimensions(512, 512) draw_scatter_plot(w, 512, target) self._assert_img_equal("scatter_28070", target)
def test_draw_grayscale_heightmap(self): w = World.open_protobuf("%s/seed_28070.world" % self.tests_data_dir) target = PNGWriter.grayscale_from_array(w.elevation['data'], scale_to_range=True) #draw_grayscale_heightmap(w, target) self._assert_img_equal("grayscale_heightmap_28070", target)
def test_draw_elevation_no_shadow(self): w = World.open_protobuf("%s/seed_28070.world" % self.tests_data_dir) data = w.elevation['data'] target = PNGWriter.rgba_from_dimensions(w.width, w.height) draw_elevation(w, False, target) self._assert_img_equal("elevation_28070_no_shadow", target)
def _on_open(self): filename = QFileDialog.getOpenFileName(self, "Open world", "", "*.world") world = World.open_protobuf(filename) self.set_world(world)
def test_locate_biomes(self): w = World.open_protobuf("%s/biome_test.world" % self.tests_data_dir) cm, biome_cm = BiomeSimulation().execute(w, 6908)
def test_draw_simple_elevation(self): w = World.open_protobuf("%s/seed_28070.world" % self.tests_data_dir) target = PixelCollector(w.width, w.height) draw_simple_elevation(w, w.sea_level(), target) self._assert_img_equal("simple_elevation_28070", target)
def test_draw_scatter_plot(self): w = World.open_protobuf("%s/seed_28070.world" % self.tests_data_dir) target = PixelCollector(16, 16) draw_scatter_plot(w, 16, target)
def test_draw_elevation_shadow(self): w = World.open_protobuf("%s/seed_28070.world" % self.tests_data_dir) data = w.elevation['data'] target = PNGWriter.rgba_from_dimensions(w.width, w.height) draw_elevation(w, True, target) self._assert_img_equal("elevation_28070_shadow", target)