def calc_star_system_positions(shape, size): """ Calculates list of positions (x, y) for a given galaxy shape, number of systems and width Uses universe generator helper functions provided by the API """ # calculate typical width for universe based on number of systems width = fo.calc_typical_universe_width(size) if shape in [fo.galaxyShape.elliptical, fo.galaxyShape.irregular]: width *= 1.4 elif shape == fo.galaxyShape.disc: width *= 1.2 print "Set universe width to", width fo.set_universe_width(width) positions = fo.SystemPositionVec() if shape == fo.galaxyShape.random: shape = choice(shapes) print "Creating", shape, "galaxy shape" if shape == fo.galaxyShape.spiral2: spiral_galaxy_calc_positions(positions, 2, size, width) elif shape == fo.galaxyShape.spiral3: spiral_galaxy_calc_positions(positions, 3, size, width) elif shape == fo.galaxyShape.spiral4: spiral_galaxy_calc_positions(positions, 4, size, width) elif shape == fo.galaxyShape.elliptical: elliptical_galaxy_calc_positions(positions, size, width) elif shape == fo.galaxyShape.disc: disc_galaxy_calc_positions(positions, size, width) elif shape == fo.galaxyShape.cluster: # Typically a galaxy with 100 systems should have ~5 clusters avg_clusters = size / 20 if avg_clusters < 2: avg_clusters = 2 # Add a bit of random variation (+/- 20%) clusters = randint((avg_clusters * 8) / 10, (avg_clusters * 12) / 10) if clusters >= 2: cluster_galaxy_calc_positions(positions, clusters, size, width) elif shape == fo.galaxyShape.ring: ring_galaxy_calc_positions(positions, size, width) elif shape == fo.galaxyShape.irregular: irregular_galaxy_calc_positions(positions, size, width) # Check if any positions have been calculated... if not positions: # ...if not, fall back on box shape box_galaxy_calc_positions(positions, size, width) # to avoid having too much "extra space" around the system positions of our galaxy map, recalculate the universe # width and shift all positions accordingly width, positions = recalc_universe_width(positions) print "Set universe width to", width fo.set_universe_width(width) return positions
def calc_star_system_positions(shape, size): """ Calculates list of positions (x, y) for a given galaxy shape, number of systems and width Uses universe generator helper functions provided by the API """ # calculate typical width for universe based on number of systems width = fo.calc_typical_universe_width(size) if shape == fo.galaxyShape.irregular2: width *= 1.4 if shape == fo.galaxyShape.elliptical: width *= 1.4 print "Set universe width to", width fo.set_universe_width(width) positions = fo.SystemPositionVec() if shape == fo.galaxyShape.random: shape = random.choice(shapes) if shape == fo.galaxyShape.spiral2: fo.spiral_galaxy_calc_positions(positions, 2, size, width, width) elif shape == fo.galaxyShape.spiral3: fo.spiral_galaxy_calc_positions(positions, 3, size, width, width) elif shape == fo.galaxyShape.spiral4: fo.spiral_galaxy_calc_positions(positions, 4, size, width, width) elif shape == fo.galaxyShape.elliptical: fo.elliptical_galaxy_calc_positions(positions, size, width, width) elif shape == fo.galaxyShape.cluster: # Typically a galaxy with 100 systems should have ~5 clusters avg_clusters = size / 20 if avg_clusters < 2: avg_clusters = 2 # Add a bit of random variation (+/- 20%) clusters = random.randint((avg_clusters * 8) / 10, (avg_clusters * 12) / 10) if clusters >= 2: fo.cluster_galaxy_calc_positions(positions, clusters, size, width, width) elif shape == fo.galaxyShape.ring: fo.ring_galaxy_calc_positions(positions, size, width, width) elif shape == fo.galaxyShape.irregular2: irregular2_galaxy_calc_positions(positions, size, width) # Check if any positions have been calculated... if not positions: # ...if not, fall back on irregular1 shape fo.irregular_galaxy_positions(positions, size, width, width) # to avoid having too much "extra space" around the system positions of our galaxy map, recalculate the universe # width and shift all positions accordingly width, positions = recalc_universe_width(positions) print "Set universe width to", width fo.set_universe_width(width) return positions
def calc_star_system_positions(gsd): """ Calculates list of positions (x, y) for a given galaxy shape, number of systems and width Uses universe generator helper functions provided by the API """ # if shape is "random", randomly pick a galaxy shape if gsd.shape == fo.galaxyShape.random: gsd.shape = choice(shapes) # calculate typical width for universe based on number of systems width = calc_universe_width(gsd.shape, gsd.size) print "Set universe width to", width fo.set_universe_width(width) positions = [] print "Creating", gsd.shape, "galaxy shape" if gsd.shape == fo.galaxyShape.spiral2: spiral_galaxy_calc_positions(positions, 2, gsd.size, width) elif gsd.shape == fo.galaxyShape.spiral3: spiral_galaxy_calc_positions(positions, 3, gsd.size, width) elif gsd.shape == fo.galaxyShape.spiral4: spiral_galaxy_calc_positions(positions, 4, gsd.size, width) elif gsd.shape == fo.galaxyShape.elliptical: elliptical_galaxy_calc_positions(positions, gsd.size, width) elif gsd.shape == fo.galaxyShape.disc: disc_galaxy_calc_positions(positions, gsd.size, width) elif gsd.shape == fo.galaxyShape.cluster: # Typically a galaxy with 100 systems should have ~5 clusters avg_clusters = gsd.size / 20 if avg_clusters < 2: avg_clusters = 2 # Add a bit of random variation (+/- 20%) clusters = randint((avg_clusters * 8) / 10, (avg_clusters * 12) / 10) if clusters >= 2: cluster_galaxy_calc_positions(positions, clusters, gsd.size, width) elif gsd.shape == fo.galaxyShape.ring: ring_galaxy_calc_positions(positions, gsd.size, width) elif gsd.shape == fo.galaxyShape.irregular: irregular_galaxy_calc_positions(positions, gsd.size, width) # Check if any positions have been calculated... if not positions: # ...if not, fall back on box shape box_galaxy_calc_positions(positions, gsd.size, width) # to avoid having too much "extra space" around the system positions of our galaxy map, recalculate the universe # width and shift all positions accordingly width, positions = recalc_universe_width(positions) print "Set universe width to", width fo.set_universe_width(width) return positions
def calc_star_system_positions(gsd): """ Calculates list of positions (x, y) for a given galaxy shape, number of systems and width Uses universe generator helper functions provided by the API """ # calculate typical width for universe based on number of systems width = calc_universe_width(gsd.shape, gsd.size) print("Set universe width to {}".format(width)) fo.set_universe_width(width) positions = [] adjacency_grid = AdjacencyGrid(width) print("Creating {} galaxy shape".format(gsd.shape)) if gsd.shape == fo.galaxyShape.spiral2: spiral_galaxy_calc_positions(positions, adjacency_grid, 2, gsd.size, width) elif gsd.shape == fo.galaxyShape.spiral3: spiral_galaxy_calc_positions(positions, adjacency_grid, 3, gsd.size, width) elif gsd.shape == fo.galaxyShape.spiral4: spiral_galaxy_calc_positions(positions, adjacency_grid, 4, gsd.size, width) elif gsd.shape == fo.galaxyShape.elliptical: elliptical_galaxy_calc_positions(positions, adjacency_grid, gsd.size, width) elif gsd.shape == fo.galaxyShape.disc: disc_galaxy_calc_positions(positions, adjacency_grid, gsd.size, width) elif gsd.shape == fo.galaxyShape.cluster: cluster_galaxy_calc_positions(positions, adjacency_grid, gsd.size, width) elif gsd.shape == fo.galaxyShape.ring: ring_galaxy_calc_positions(positions, adjacency_grid, gsd.size, width) elif gsd.shape == fo.galaxyShape.irregular: irregular_galaxy_calc_positions(positions, adjacency_grid, gsd.size, width) # Check if any positions have been calculated... if not positions: # ...if not, fall back on box shape box_galaxy_calc_positions(positions, adjacency_grid, gsd.size, width) enforce_max_distance(positions, adjacency_grid) # to avoid having too much "extra space" around the system positions of our galaxy map, recalculate the universe # width and shift all positions accordingly width, positions = recalc_universe_width(positions) print("Set universe width to {}".format(width)) fo.set_universe_width(width) return positions
def calc_star_system_positions(shape, size): """ Calculates list of positions (x, y) for a given galaxy shape, number of systems and width Uses universe generator helper functions provided by the API """ # calculate typical width for universe based on number of systems width = fo.calc_typical_universe_width(size) if shape == fo.galaxyShape.irregular2: width *= 1.4 if shape == fo.galaxyShape.elliptical: width *= 1.4 fo.set_universe_width(width) print "Set universe width to", width positions = fo.SystemPositionVec() if shape == fo.galaxyShape.random: shape = random.choice(shapes) if shape == fo.galaxyShape.spiral2: fo.spiral_galaxy_calc_positions(positions, 2, size, width, width) elif shape == fo.galaxyShape.spiral3: fo.spiral_galaxy_calc_positions(positions, 3, size, width, width) elif shape == fo.galaxyShape.spiral4: fo.spiral_galaxy_calc_positions(positions, 4, size, width, width) elif shape == fo.galaxyShape.elliptical: fo.elliptical_galaxy_calc_positions(positions, size, width, width) elif shape == fo.galaxyShape.cluster: # Typically a galaxy with 100 systems should have ~5 clusters avg_clusters = size / 20 if avg_clusters < 2: avg_clusters = 2 # Add a bit of random variation (+/- 20%) clusters = random.randint((avg_clusters * 8) / 10, (avg_clusters * 12) / 10) if clusters >= 2: fo.cluster_galaxy_calc_positions(positions, clusters, size, width, width) elif shape == fo.galaxyShape.ring: fo.ring_galaxy_calc_positions(positions, size, width, width) elif shape == fo.galaxyShape.irregular2: irregular2_galaxy_calc_positions(positions, size, width) # Check if any positions have been calculated... if not positions: # ...if not, fall back on irregular1 shape fo.irregular_galaxy_positions(positions, size, width, width) return positions
def calc_star_system_positions(gsd): """ Calculates list of positions (x, y) for a given galaxy shape, number of systems and width Uses universe generator helper functions provided by the API """ # calculate typical width for universe based on number of systems width = calc_universe_width(gsd.shape, gsd.size) print "Set universe width to {}".format(width) fo.set_universe_width(width) positions = [] adjacency_grid = AdjacencyGrid(width) print "Creating {} galaxy shape".format(gsd.shape) if gsd.shape == fo.galaxyShape.spiral2: spiral_galaxy_calc_positions(positions, adjacency_grid, 2, gsd.size, width) elif gsd.shape == fo.galaxyShape.spiral3: spiral_galaxy_calc_positions(positions, adjacency_grid, 3, gsd.size, width) elif gsd.shape == fo.galaxyShape.spiral4: spiral_galaxy_calc_positions(positions, adjacency_grid, 4, gsd.size, width) elif gsd.shape == fo.galaxyShape.elliptical: elliptical_galaxy_calc_positions(positions, adjacency_grid, gsd.size, width) elif gsd.shape == fo.galaxyShape.disc: disc_galaxy_calc_positions(positions, adjacency_grid, gsd.size, width) elif gsd.shape == fo.galaxyShape.cluster: cluster_galaxy_calc_positions(positions, adjacency_grid, gsd.size, width) elif gsd.shape == fo.galaxyShape.ring: ring_galaxy_calc_positions(positions, adjacency_grid, gsd.size, width) elif gsd.shape == fo.galaxyShape.irregular: irregular_galaxy_calc_positions(positions, adjacency_grid, gsd.size, width) # Check if any positions have been calculated... if not positions: # ...if not, fall back on box shape box_galaxy_calc_positions(positions, adjacency_grid, gsd.size, width) enforce_max_distance(positions, adjacency_grid) # to avoid having too much "extra space" around the system positions of our galaxy map, recalculate the universe # width and shift all positions accordingly width, positions = recalc_universe_width(positions) print "Set universe width to {}".format(width) fo.set_universe_width(width) return positions