diff --git a/stargen.py b/stargen.py index 0337d31..34683ed 100644 --- a/stargen.py +++ b/stargen.py @@ -108,14 +108,18 @@ star_lumin = [(500000.0, 30000.0), (30000.0, 25.0), (25.0, 5.0), (5.0, 1.5), (1. star_masses = [(40.0, 16.0), (16.0, 2.1), (2.1, 1.4), (1.4, 1.04), (1.04, 0.8), (0.8, 0.45), (0.45, 0.1)] star_radii = [(22.0, 8.0), (7.0, 1.8), (1.8, 1.4), (1.4, 1.15), (1.15, 0.96), (0.96, 0.7), (0.7, 0.25)] star_prob = [0.0, 0.05, 0.35, 0.6, 0.8, 0.97, 1.0] +gen_counter = 0 +starsys_counter = 0 def dist(x, y, z): return math.sqrt(x**2 + y**2 + z**2) def gen_system(force_habitable=False): + global gen_counter single = True system_habitable = False while single or (force_habitable and not system_habitable): + gen_counter += 1 single = False num_stars = round(gaussian(*stars_randcount)) if num_stars < 1.0: @@ -234,14 +238,21 @@ def gen_system(force_habitable=False): continue atmo = None + atmo_count = 0 while atmo == None or atmo > density: + atmo_count += 1 if gas_giant: - atmo_exp = randrange(2.0, 12.0) + atmo_exp = randrange(-5.0, 12.0) else: - atmo_exp = randrange(-9, 2.0) + atmo_exp = randrange(-9.0, 2.0) atmo = 1.3 ** atmo_exp + if atmo_count > 50 and atmo > density: + print "ATMO FAIL for gasgiant:%s, wanted less than %f, kept getting values like %f due to exponent %f" % (gas_giant, density, atmo, atmo_exp) + atmo = 1.3 ** (atmo_exp - 10.0) + break + albedo = -1.0 while albedo <= 0.01 or albedo >= 0.99: albedo = gaussian(0.35, 0.25) @@ -342,7 +353,10 @@ def main(): for syst in systems: print_system(syst, False) - print color("\n ***************** UNINHABITABLE SYSTEMS (%d) *****************\x1b[0;37m\n", 'm', 1) % (len(dead_systems),) + ansi_cancel = "" + if os.name == "posix": + ansi_cancel = "\x1b[0;37m" + print color("\n ***************** UNINHABITABLE SYSTEMS (%d) *****************%s\n", 'm', 1) % (len(dead_systems), ansi_cancel) for syst in dead_systems: print_system(syst, False)