Beispiel #1
0
 def generate(self, width, height, density, seed=None):
     """
     Setup this galaxy with the correct width, height and generate the new planets.
     """
     self.width = width
     self.height = height
     
     maxPlanets = (self.width-2) * (self.height-2) * density
     prng = random.Random(seed)
     while len(self.planets) < maxPlanets:
         x = prng.randint(1, self.width-1)
         y = prng.randint(1, self.height-1)
         if (x,y) not in self.planets:
             newPlanet = Planet(x,y)
             newPlanet.generate(prng)
             self.planets[(x,y)] = newPlanet
     return