Example #1
0
 def __init__(
     self,
     seed,
     name,
     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,
 ):
     self.name = name
     self.width = width
     self.height = height
     self.seed = seed
     self.n_plates = num_plates
     self.ocean_level = sea_level
     self.p = platec.create(
         seed,
         width,
         height,
         sea_level,
         erosion_period,
         folding_ratio,
         aggr_overlap_abs,
         aggr_overlap_rel,
         cycle_count,
         num_plates,
     )
     self.steps = 0
Example #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,
                               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
Example #3
0
 def test_is_finished(self):
     seed = 1
     width = 100
     height = 100
     p = platec.create(seed, width, height, 0.65, 60, 0.02, 1000000, 0.33, 2, 10)
     platec.destroy(p)
     self.assertEqual(False, platec.is_finished(p))
Example #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,
                               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
Example #5
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
Example #6
0
 def test_get_platesmap(self):
     seed = 1
     width = 100
     height = 100
     p = platec.create(seed, width, height, 0.65, 60, 0.02, 1000000, 0.33, 2, 10)
     pm = platec.get_platesmap(p)
     platec.destroy(p)
     self.assertEqual(10000, len(pm))
     for v in pm:
         self.assertTrue(10 > v >= 0)
Example #7
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)
Example #8
0
 def __init__(self, seed, name, 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):
     self.name = name
     self.width = width
     self.height = height
     self.seed = seed
     self.n_plates = num_plates
     self.ocean_level = sea_level
     self.p = platec.create(seed, width, height, sea_level, erosion_period,
                            folding_ratio,
                            aggr_overlap_abs, aggr_overlap_rel, cycle_count,
                            num_plates)
     self.steps = 0
Example #9
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
Example #10
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
Example #11
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
Example #12
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
Example #13
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
Example #14
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
Example #15
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
Example #16
0
 def test_create(self):
     seed = 1
     width = 100
     height = 100
     p = platec.create(seed, width, height, 0.65, 60, 0.02, 1000000, 0.33, 2, 10)
     platec.destroy(p)