Skip to content

Instantly share code, notes, and snippets.

@jaytaylor
Last active January 10, 2018 23:59
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 jaytaylor/d512873fd9856e1d1dc7f48ed7304601 to your computer and use it in GitHub Desktop.
Save jaytaylor/d512873fd9856e1d1dc7f48ed7304601 to your computer and use it in GitHub Desktop.
Super simple random name generator.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Inspired by https://stackoverflow.com/a/5732034/293064
"""
import random
input_text = '''
[color]
red
green
blue
yellow
orange
purple
violet
magenta
brown
tan
turquoise
black
white
gray
rose
maroon
charcoal
[adjective]
windy
dusty
sappy
clean
happy
sad
prickly
loud
bright
blinking
burning
hot
firey
freezing
frozen
toasted
spicy
big
small
tiny
old
young
grassy
silly
[noun]
turtle
rabbit
tiger
bear
pug
sloth
cricket
toad
ape
chimp
bat
bird
stallion
horse
hound
camel
salad
castle
palace
cave
beach
forest
desert
atoll
sand
rain
wind
water
trousers
shorts
shirt
pant
sock
dinner
magician
hero
knight
villain
vandal
prince
slouch
goon
violin
delorean
fire
ice
bread
ding
library
dust
sand
plan
home
wand
pond
grass
'''.strip()
_parts = {}
current_index = []
for line in input_text.split('\n'):
line = line.strip()
if len(line) == 0:
continue
if line.startswith('[') and line.endswith(']'):
current_index = []
_parts[line[1:-1]] = current_index
else:
current_index.append(line.strip())
del input_text, current_index, line
def roll():
# parts_keys = _parts.keys()
parts_keys = ['color', 'adjective']
random.shuffle(parts_keys)
name = '-'.join(random.choice(_parts[key]) for key in parts_keys + ['noun'])
return name
if __name__ == '__main__':
import sys
n = 1
if len(sys.argv) > 1 and sys.argv[1].isdigit():
n = int(sys.argv[1])
for i in xrange(n):
print(roll())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment