예제 #1
0
def generate_plates_simulation(seed,
                               width,
                               height,
                               sea_level=0.65,
                               erosion_period=60,
                               folding_ratio=0.02,
                               aggr_overlap_abs=1000000,
                               aggr_overlap_rel=0.33,
                               cycle_count=2,
                               num_plates=10,
                               verbose=get_verbose()):

    if verbose:
        start_time = time.time()
    p = platec.create(seed, width, height, sea_level, erosion_period,
                      folding_ratio, aggr_overlap_abs, aggr_overlap_rel,
                      cycle_count, num_plates)

    while platec.is_finished(p) == 0:
        # TODO: add a if verbose: message here?
        platec.step(p)
    hm = platec.get_heightmap(p)
    pm = platec.get_platesmap(p)
    if verbose:
        elapsed_time = time.time() - start_time
        print("...plates.generate_plates_simulation() complete. " +
              "Elapsed time " + str(elapsed_time) + " seconds.")
    return hm, pm
예제 #2
0
def generate_plates_simulation(seed,
                               width,
                               height,
                               sea_level=0.65,
                               erosion_period=60,
                               folding_ratio=0.02,
                               aggr_overlap_abs=1000000,
                               aggr_overlap_rel=0.33,
                               cycle_count=2,
                               num_plates=10,
                               map_side=512):
    """We typically use low map_side for plates simulation (512) and scale the resulting map later/
    Specifying higher values we increase simulation time and quality. Consider that only
    power of 2 are valid inputs.
    """

    p = platec.create(seed, map_side, sea_level, erosion_period, folding_ratio,
                      aggr_overlap_abs, aggr_overlap_rel, cycle_count,
                      num_plates)

    while platec.is_finished(p) == 0:
        platec.step(p)
    hm = platec.get_heightmap(p)

    hm = scale_map_in_array(hm, map_side, map_side, width, height)

    return hm
예제 #3
0
def generate_heightmap(seed, width, height):
    """Takes seed, width, height (other variables built in), returns a dictionary heightmap"""

    sea_level = 0.65
    erosion_period = 60
    folding_ratio = 0.02
    aggr_overlap_abs = 1000000
    aggr_overlap_rel = 0.33
    cycle_count = 2
    num_plates = 10

    p = platec.create(seed, width, height, sea_level, erosion_period,
                      folding_ratio, aggr_overlap_abs, aggr_overlap_rel,
                      cycle_count, num_plates)
    while platec.is_finished(p) == 0:
        platec.step(p)

    hmap = platec.get_heightmap(p)
    # pm = platec.get_platesmap(p)

    platec.destroy(p)

    int_hmap = [int(round(h)) for h in hmap]

    heightmap = np.reshape(int_hmap, (width, height))

    print max(hmap)

    # height_dict = {}
    # for z, row in enumerate(heightmap):
    #     for x, h in enumerate(row):
    #         for y in range(h + 1):
    #             height_dict[(x, y, z)] = 6 if h == 0 else (1 if y == h else (3 if y <= h - 3 else 2))

    return hmap
예제 #4
0
 def world(self):
     world = World(self.name, self.width, self.height, self.seed,
                   self.n_plates, self.ocean_level,
                   Step.get_by_name("plates"))
     hm = platec.get_heightmap(self.p)
     pm = platec.get_platesmap(self.p)
     world.set_elevation(array_to_matrix(hm, self.width, self.height), None)
     world.set_plates(array_to_matrix(pm, self.width, self.height))
     return world
예제 #5
0
 def world(self):
     world = World(self.name, self.width, self.height, self.seed,
                   self.n_plates, self.ocean_level,
                   Step.get_by_name("plates"))
     hm = platec.get_heightmap(self.p)
     pm = platec.get_platesmap(self.p)
     world.set_elevation(array_to_matrix(hm, self.width, self.height), None)
     world.set_plates(array_to_matrix(pm, self.width, self.height))
     return world
예제 #6
0
 def test_get_heightmap(self):
     seed = 1
     width = 100
     height = 100
     p = platec.create(seed, width, height, 0.65, 60, 0.02, 1000000, 0.33, 2, 10)
     hm = platec.get_heightmap(p)
     platec.destroy(p)
     self.assertEqual(10000, len(hm))
     for v in hm:
         self.assertTrue(v >= 0.0)
예제 #7
0
def generate_plates_simulation(obj, seed, width, height, sea_level=0.65,
                               erosion_period=60, folding_ratio=0.02,
                               aggr_overlap_abs=1000000, aggr_overlap_rel=0.33,
                               cycle_count=2, num_plates=10):

    p = platec.create(seed, width, height, sea_level, erosion_period,
                      folding_ratio, aggr_overlap_abs, aggr_overlap_rel,
                      cycle_count, num_plates)
    # Note: To rescale the worlds heightmap to roughly Earths scale, multiply by 2000.

    while platec.is_finished(p) == 0:
        platec.step(p)
    
    hm = platec.get_heightmap(p)
    pm = platec.get_platesmap(p)
    
    return hm, pm
예제 #8
0
파일: plates.py 프로젝트: SourceRyan/lands
def generate_plates_simulation(seed, width, height, sea_level=0.65, erosion_period=60,
                               folding_ratio=0.02, aggr_overlap_abs=1000000, aggr_overlap_rel=0.33,
                               cycle_count=2, num_plates=10, map_side=512):
    """We typically use low map_side for plates simulation (512) and scale the resulting map later/
    Specifying higher values we increase simulation time and quality. Consider that only
    power of 2 are valid inputs.
    """

    p = platec.create(seed, map_side, sea_level, erosion_period, folding_ratio,
                      aggr_overlap_abs, aggr_overlap_rel, cycle_count, num_plates)

    while platec.is_finished(p) == 0:
        platec.step(p)
    hm = platec.get_heightmap(p)

    hm = scale_map_in_array(hm, map_side, map_side, width, height)

    return hm
예제 #9
0
def generate_plates_simulation(seed, width, height, sea_level=0.65,
                               erosion_period=60, folding_ratio=0.02,
                               aggr_overlap_abs=1000000, aggr_overlap_rel=0.33,
                               cycle_count=2, num_plates=10,
                               verbose=get_verbose()):

    if verbose:
        start_time = time.time()
    p = platec.create(seed, width, height, sea_level, erosion_period,
                      folding_ratio, aggr_overlap_abs, aggr_overlap_rel,
                      cycle_count, num_plates)

    while platec.is_finished(p) == 0:
        # TODO: add a if verbose: message here?
        platec.step(p)
    hm = platec.get_heightmap(p)
    pm = platec.get_platesmap(p)
    if verbose:
        elapsed_time = time.time() - start_time
        print("...plates.generate_plates_simulation() complete. " +
              "Elapsed time " + str(elapsed_time) + " seconds.")
    return hm, pm
예제 #10
0
def generate_heightmap(seed, width, height):
    """Takes seed, width, height (other variables built in), returns a
    dictionary heightmap. Keys: (x,y,z) coordinate tuples, Values: block IDs"""

    # various built-in tectonics variables
    sea_level = 0.65
    erosion_period = 60
    folding_ratio = 0.02
    aggr_overlap_abs = 1000000
    aggr_overlap_rel = 0.33
    cycle_count = 2
    num_plates = 10

    # runs plate tectonics simulation based on given and built in variables,
    # assigned to simulation variable p
    p = platec.create(seed, width, height, sea_level, erosion_period,
                        folding_ratio, aggr_overlap_abs,
                        aggr_overlap_rel, cycle_count, num_plates)
    while platec.is_finished(p) == 0:
        platec.step(p)

    # grabs a list of height values from p, assigns to hmap
    hmap = platec.get_heightmap(p)
    #pmap = platec.get_platesmap(p)

    # removes simulation from memory
    platec.destroy(p)

    # converts to other useful formats, including an actual array instead of a list
    # int_hmap = [int(round(h)) for h in hmap]
    heightmap = np.reshape(hmap,(width,height))

    # for testing
    # print max(hmap)

    # builds height dictionary from int_hmap coordinates and block IDs
    return heightmap
예제 #11
0
def generate_heightmap(seed, width, height):
    """Takes seed, width, height (other variables built in), returns a
    dictionary heightmap. Keys: (x,y,z) coordinate tuples, Values: block IDs"""

    # various built-in tectonics variables
    sea_level = 0.65
    erosion_period = 60
    folding_ratio = 0.02
    aggr_overlap_abs = 1000000
    aggr_overlap_rel = 0.33
    cycle_count = 2
    num_plates = 10

    # runs plate tectonics simulation based on given and built in variables,
    # assigned to simulation variable p
    p = platec.create(seed, width, height, sea_level, erosion_period,
                      folding_ratio, aggr_overlap_abs, aggr_overlap_rel,
                      cycle_count, num_plates)
    while platec.is_finished(p) == 0:
        platec.step(p)

    # grabs a list of height values from p, assigns to hmap
    hmap = platec.get_heightmap(p)
    #pmap = platec.get_platesmap(p)

    # removes simulation from memory
    platec.destroy(p)

    # converts to other useful formats, including an actual array instead of a list
    int_hmap = [int(round(h)) for h in hmap]
    heightmap = np.reshape(int_hmap, (width, height))

    # for testing
    # print max(hmap)

    # builds height dictionary from int_hmap coordinates and block IDs
    return heightmap
예제 #12
0
def generate_heightmap(seed, width, height):
    """Takes seed, width, height (other variables built in), returns a dictionary heightmap"""

    sea_level = 0.65
    erosion_period = 60
    folding_ratio = 0.02
    aggr_overlap_abs = 1000000
    aggr_overlap_rel = 0.33
    cycle_count = 2
    num_plates = 10

    p = platec.create(seed, width, height, sea_level, erosion_period,
                        folding_ratio, aggr_overlap_abs,
                        aggr_overlap_rel, cycle_count, num_plates)
    while platec.is_finished(p) == 0:
        platec.step(p)

    hmap = platec.get_heightmap(p)
    # pm = platec.get_platesmap(p)

    platec.destroy(p)

    int_hmap = [int(round(h)) for h in hmap]

    heightmap = np.reshape(int_hmap,(width,height))
    

    print max(hmap)

    # height_dict = {}
    # for z, row in enumerate(heightmap):
    #     for x, h in enumerate(row):
    #         for y in range(h + 1):
    #             height_dict[(x, y, z)] = 6 if h == 0 else (1 if y == h else (3 if y <= h - 3 else 2))

    return hmap
예제 #13
0
def generate_plates_simulation(obj,
                               seed,
                               width,
                               height,
                               sea_level=0.65,
                               erosion_period=60,
                               folding_ratio=0.02,
                               aggr_overlap_abs=1000000,
                               aggr_overlap_rel=0.33,
                               cycle_count=2,
                               num_plates=10):

    p = platec.create(seed, width, height, sea_level, erosion_period,
                      folding_ratio, aggr_overlap_abs, aggr_overlap_rel,
                      cycle_count, num_plates)
    # Note: To rescale the worlds heightmap to roughly Earths scale, multiply by 2000.

    while platec.is_finished(p) == 0:
        platec.step(p)

    hm = platec.get_heightmap(p)
    pm = platec.get_platesmap(p)

    return hm, pm