def find_planet(self): for s in Star.all_: for p in s.planets: if p.active_solvent is not None and p.solvents[p.active_solvent] > 0.5 and p.owner is None: p.owner = self for s, l in zip(p.structures, "TCMLS"): s.plan = plan(l) s.health = 100 p.storage += {m: 5000 for m in metals()} if Team.UI_base is self: p.show() return True return False
def __init__(self, parent, index): self.parent = parent self.index = index self.mass = lograndom(10 ** -2, 70) * 10 ** index self.distance = lograndom(0.03, 0.3) * 10 ** index self.metals = OrderedDict((m, random.random() ** 3) for m in metals()) self.solvents = OrderedDict((s, random.random() ** 3) for s in solvents()) self.dispsize = (log_to_rel(self.mass, 10 ** -2, 7000) + 0.1) * 20 self.dispdist = log_to_rel(self.distance, 0.03, 300) * 300 + 100 self.color = usecolorstring(log_to_rel(self.mass, 10 ** -2, 7000), [(127, 127, 127), (255, 255, 127)]) self.structures = [Structure(self) for _ in range(5)] self.name = generate_name() self.owner = None self.storage = Counter(self.solvents.keys()) self.storage.update(self.metals.keys()) self.population = 0 self.temperature_max = 300 / self.distance / self.parent.mass self.temperature_min = self.temperature_max * 0.8 self.pressure = self.mass ** 1 / 3 self.active_solvent = find_solvent(self.temperature_max, self.pressure) self.buildable = self.active_solvent is not None self.autofire = True self.counter = 0 self.pos = self.decide_pos()
def getinfo(self): for i, m in enumerate(metals()): yield ( m.name, "{:>4}/{:>4.0f}".format(sum(ship(s).cost.get(m, 0) for s in self.ships), self.planet.storage[m]), )