예제 #1
0
 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"]
예제 #2
0
    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)
예제 #3
0
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")
예제 #4
0
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")
예제 #5
0
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")
예제 #6
0
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")
예제 #7
0
 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)
예제 #8
0
 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)
예제 #9
0
 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)
예제 #10
0
 def setUp(self):
     super(TestDrawingFunctions, self).setUp()
     self.w = World.open_protobuf("%s/seed_28070.world" %
                                  self.tests_data_dir)
예제 #11
0
 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)
예제 #12
0
 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)
예제 #13
0
 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)
예제 #14
0
 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 setUp(self):
     super(TestDrawingFunctions, self).setUp()
     self.w = World.open_protobuf("%s/seed_28070.world" % self.tests_data_dir)
예제 #16
0
 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)
예제 #17
0
 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)
예제 #18
0
 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)
예제 #19
0
 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)
예제 #20
0
 def _on_open(self):
     filename = QFileDialog.getOpenFileName(self, "Open world", "",
                                            "*.world")
     world = World.open_protobuf(filename)
     self.set_world(world)
예제 #21
0
 def test_locate_biomes(self):
     w = World.open_protobuf("%s/biome_test.world" % self.tests_data_dir)
     cm, biome_cm = BiomeSimulation().execute(w, 6908)
예제 #22
0
 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)
예제 #23
0
 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)
예제 #24
0
 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)
예제 #25
0
 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)
예제 #26
0
 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)
예제 #27
0
 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)
예제 #28
0
 def test_locate_biomes(self):
     w = World.open_protobuf("%s/biome_test.world" % self.tests_data_dir)
     cm, biome_cm = BiomeSimulation().execute(w, 6908)
예제 #29
0
 def _on_open(self):
     filename = QFileDialog.getOpenFileName(self, "Open world", "",
                                                  "*.world")
     world = World.open_protobuf(filename)
     self.set_world(world)
예제 #30
0
 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)