Beispiel #1
0
 def make_river(self):
     lowpoints = []
     target_nodes = []
     for x in range(self.width):
         for y in range(self.height):
             if self.heightmap[x][y] < 0.7:
                 lowpoints.append((x, y))
     random.shuffle(lowpoints)
     target_nodes.append(lowpoints[0])
     lowpoints.pop(0)
     while len(target_nodes) < 25:
         c = lowpoints[0]
         for tn in target_nodes:
             if check_range(c, tn, 10):
                 lowpoints.pop(0)
                 continue
         else:
             target_nodes.append(c)
             lowpoints.pop(0)
     r = gen_river(
         self.width, self.height, startnode=(32, 32), numnodes=100,
         custom_nodes=target_nodes
     )
     for px, py in r:
         for x, y in [(px + i, py + j) for i in (-3, 0, 3) for j in (-3, 0, 3) if i != 0 or j != 0]:
             try:
                 if self.heightmap[x][y] > 0:
                     self.heightmap[x][y] *= 0.8
             except IndexError:
                 pass
         for x, y in [(px + i, py + j) for i in (-2, 0, 2) for j in (-2, 0, 2) if i != 0 or j != 0]:
             try:
                 if self.heightmap[x][y] > 0:
                     self.heightmap[x][y] *= 0.8
             except IndexError:
                 pass
         for x, y in [(px + i, py + j) for i in (-1, 0, 1) for j in (-1, 0, 1) if i != 0 or j != 0]:
             try:
                 if self.heightmap[x][y] > 0:
                     self.heightmap[x][y] *= 0.6
             except IndexError:
                 pass
         self.heightmap[px][py] = 0.
Beispiel #2
0
 def check_in_colony(self, x, y):
     return check_range((x, y), (self.x, self.y), self.size + 1)