Ejemplo n.º 1
0
 def add_noise(self):
     for x, y in itertools.product(range(self.width), range(self.height)):
         if self.get(x, y).is_wall:
             # the_noise = (noise.snoise2(x, y, 10) + 1) / 2
             # the_noise = numpy.random.uniform()
             the_noise = mn.simplex_noise_2d(x, y)
             self.get(int(x), int(y)).colour = (the_noise, the_noise, the_noise, 0)
     return self
Ejemplo n.º 2
0
 def add_noise(self):
     for x, y in itertools.product(range(self.width), range(self.height)):
         if self.get(x, y).is_wall:
             # the_noise = (noise.snoise2(x, y, 10) + 1) / 2
             # the_noise = numpy.random.uniform()
             the_noise = mn.simplex_noise_2d(x, y)
             self.get(int(x),
                      int(y)).colour = (the_noise, the_noise, the_noise, 0)
     return self
Ejemplo n.º 3
0
def add_resources(the_map: world.Map, food_threshold=0.85, money_threshold=0.15):
    for x, y in itertools.product(range(the_map.width), range(the_map.height)):
        if the_map.get(x, y).is_wall:
            the_noise = mn.simplex_noise_2d(x, y)
            if the_noise > food_threshold:
                the_map.set(FoodTile(), x, y, 0)
            elif the_noise < money_threshold:
                the_map.set(MoneyTile(), x, y, 0)
    return the_map
Ejemplo n.º 4
0
def add_resources(the_map: world.Map,
                  food_threshold=0.85,
                  money_threshold=0.15):
    for x, y in itertools.product(range(the_map.width), range(the_map.height)):
        if the_map.get(x, y).is_wall:
            the_noise = mn.simplex_noise_2d(x, y)
            if the_noise > food_threshold:
                the_map.set(FoodTile(), x, y, 0)
            elif the_noise < money_threshold:
                the_map.set(MoneyTile(), x, y, 0)
    return the_map
Ejemplo n.º 5
0
 def add_noise(self, branches=32):
     numpy.random.seed(self.seed)
     rnd = iter(numpy.random.randint(0, 1000, branches))
     for n in rnd:
         x = 0
         y = self.height / 2
         for i in range(self.width * 2):
             the_noise = mn.simplex_noise_2d(x, y, self.seed) * numpy.pi
             x -= numpy.cos(the_noise) / 2
             y += numpy.sin(the_noise) * 2
             if 0 < x < self.width and 0 < y < self.height:
                 self.set(crevasse.CrevasseTile(), int(x), int(y))
     return self
Ejemplo n.º 6
0
 def add_noise(self, branches=32):
     numpy.random.seed(self.seed)
     rnd = iter(numpy.random.randint(0, 1000, branches))
     for n in rnd:
         x = 0
         y = self.height / 2
         for i in range(self.width * 2):
             the_noise = mn.simplex_noise_2d(x, y, self.seed) * numpy.pi
             x -= numpy.cos(the_noise) / 2
             y += numpy.sin(the_noise) * 2
             if 0 < x < self.width and 0 < y < self.height:
                 self.set(crevasse.CrevasseTile(), int(x), int(y))
     return self
Ejemplo n.º 7
0
 def add_noise(self, branches=360):
     numpy.random.seed(self.seed)
     rnd = iter(numpy.random.randint(0, 1000, branches))
     offset = 0
     offset_adjust = branches / 2 / numpy.pi
     for n in rnd:
         x = self.width / 2
         y = self.height / 2
         for i in range(self.width):
             the_noise = mn.simplex_noise_2d(n, i, self.seed) * 2 * numpy.pi + offset
             x += numpy.sin(the_noise)
             y += numpy.cos(the_noise)
             if 0 < x < self.width and 0 < y < self.height:
                 self.get(int(x), int(y)).colour[0] += 0.3
         offset += offset_adjust
     return self
Ejemplo n.º 8
0
 def add_noise(self, branches=360):
     numpy.random.seed(self.seed)
     rnd = iter(numpy.random.randint(0, 1000, branches))
     offset = 0
     offset_adjust = branches / 2 / numpy.pi
     for n in rnd:
         x = self.width / 2
         y = self.height / 2
         for i in range(self.width):
             the_noise = mn.simplex_noise_2d(
                 n, i, self.seed) * 2 * numpy.pi + offset
             x += numpy.sin(the_noise)
             y += numpy.cos(the_noise)
             if 0 < x < self.width and 0 < y < self.height:
                 self.get(int(x), int(y)).colour[0] += 0.3
         offset += offset_adjust
     return self
Ejemplo n.º 9
0
def make_noise_height_map(width, height, seed, octaves):
    hm = HeightMap(width, height)
    for x, y in itertools.product(range(hm.width), range(hm.height)):
        hm.set(x, y, mn.simplex_noise_2d(x, y, seed, octaves))
    return hm