示例#1
0
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
示例#2
0
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
示例#3
0
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