def create_world(self): from creatures import Predator, Herbivore, Plant if self.density < 1 or self.density > 100: sys.exit() world = World(cols=self.cols, rows=self.rows) cnt = int(world.cols * world.rows * 0.01 * self.density / 3) for i in xrange(cnt): pos = world.get_rnd_free_space() if pos is None: break creature = Predator(x=pos[0], y=pos[1]) world.queue.append((i * 21, creature)) for i in xrange(cnt): pos = world.get_rnd_free_space() if pos is None: break creature = Herbivore(x=pos[0], y=pos[1]) world.queue.append((i * 22, creature)) for i in xrange(cnt): pos = world.get_rnd_free_space() if pos is None: break creature = Plant(x=pos[0], y=pos[1]) world.queue.append((i * 23, creature)) world.start(0.1) return world