Exemplo n.º 1
0
 def step(self):
     if platec.is_finished(self.p) == 0:
         platec.step(self.p)
         self.steps += 1
         return False, self.steps
     else:
         return True, self.steps
Exemplo n.º 2
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
Exemplo n.º 3
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
Exemplo n.º 4
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
Exemplo n.º 5
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
Exemplo n.º 6
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