示例#1
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))
示例#2
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
示例#3
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)
示例#4
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)
示例#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
示例#6
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
示例#7
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
示例#8
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)