Skip to content

Instantly share code, notes, and snippets.

@aniongithub
Created April 4, 2023 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aniongithub/34fa76ad9afcb8f2988a0aa03c13d5e0 to your computer and use it in GitHub Desktop.
Save aniongithub/34fa76ad9afcb8f2988a0aa03c13d5e0 to your computer and use it in GitHub Desktop.
Stargate SGC planet designation creator
import random
import string
def generate_sgc_planet_designation(galaxy='Milky Way', include_char=True):
# Quadrants: M (Milky Way) or P (Pegasus)
quadrant = 'M' if galaxy == 'Milky Way' else 'P'
# Region within the quadrant (1-9)
region = random.randint(1, 9)
# Separator letter (A-Z, except for the quadrant letter)
separator = random.choice([char for char in string.ascii_uppercase if char != quadrant])
# Planet number or alphanumeric combination
if include_char and random.random() < 0.2: # 20% chance to include a character in the second group
planet = ''.join([str(random.randint(0, 9)) if random.random() < 0.8 else random.choice(string.ascii_uppercase) for _ in range(3)])
else:
planet = f'{random.randint(100, 999)}'
return f'{quadrant}{region}{separator}-{planet}'
# Test the function
for _ in range(5):
print(generate_sgc_planet_designation(galaxy='Milky Way', include_char=True))
print()
for _ in range(5):
print(generate_sgc_planet_designation(galaxy='Pegasus', include_char=True))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment