import numpy as np import random import logging logging.basicConfig(filename="gwendolyn.log", level=logging.INFO) def make_pairs(corpus): for i in range(len(corpus)-1): yield (corpus[i], corpus[i+1]) def nameGen(): names = open('resources/names.txt', encoding='utf8').read() corpus = list(names) pairs = make_pairs(corpus) word_dict = {} for word_1, word_2 in pairs: if word_1 in word_dict.keys(): word_dict[word_1].append(word_2) else: word_dict[word_1] = [word_2] first_word = random.choice(corpus) while first_word.islower() or first_word == " " or first_word == "-" or first_word == "\n": first_word = random.choice(corpus) chain = [first_word] done = False while done == False: new_letter = random.choice(word_dict[chain[-1]]) chain.append(new_letter) if new_letter == "\n": done = True genName = "".join(chain) print("Generated "+genName) logging.info("Generated "+genName) return(genName) def tavernGen(): fp = ["The Silver","The Golden","The Staggering","The Laughing","The Prancing","The Gilded","The Running","The Howling","The Slaughtered","The Leering","The Drunken","The Leaping","The Roaring","The Frowning","The Lonely","The Wandering","The Mysterious","The Barking","The Black","The Gleaming","The Tap-Dancing","The Sad","The Sexy","The Artificial","The Groovy","The Merciful","The Confused","The Pouting","The Horny","The Okay","The Friendly","The Hungry","The Handicapped","The Fire-breathing","The One-Eyed","The Psychotic","The Mad","The Evil","The Idiotic","The Trusty","The Busty"] sp = ["Eel","Dolphin","Dwarf","Pegasus","Pony","Rose","Stag","Wolf","Lamb","Demon","Goat","Spirit","Horde","Jester","Mountain","Eagle","Satyr","Dog","Spider","Star","Dad","Rat","Jeremy","Mouse","Unicorn","Pearl","Ant","Crab","Penguin","Octopus","Lawyer","Ghost","Toad","Handjob","Immigrant","SJW","Dragon","Bard","Sphinx","Soldier","Salmon","Owlbear","Kite","Frost Giant","Arsonist"] tp = [" Tavern"," Inn","","","","","","","","",""] genTav = random.choice(fp)+" "+random.choice(sp)+random.choice(tp) print("Generated "+genTav) logging.info("Generated "+genTav) return(genTav)