Last active
February 27, 2017 02:32
-
-
Save skurmedel/2a9100ab49b7cd20c56f to your computer and use it in GitHub Desktop.
Generates Gam3r part names. Sometimes gives legit names. Now with more Phantom.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import sys | |
import random | |
from types import SimpleNamespace | |
import string | |
manufacturers = ["ASUS", "ASrock", "Acer", "MSI", "Gigabyte", "XFX", "BFG", "Corsair", "EVGA", "ZOTAC", "Razer"] | |
words = {"X", "KILLER", "Sniper", "Ghost", "Adder", "Viper", "Stalker", "Force", "Gh0st", "Slayer", "Essence", "Razor", "Eraser", "Sweeper", "Blaster", "1337", "Storm", "One", "Quantum", "Quark", "Atom", "Slicer", "Millenium", "Phantom", "Hydra", "Droid", "Robot", "Phoenix", "Cyclops", "Hercules", "Caesar", "Green Beret", "Ocean", "Wave", "Break", "Destroyer", "Fighter", "Missile", "Naga", "Thor", "Odin", "Mjolnir", "Battle", "Ogre", "Lightning", "Hurricane", "Tornado", "Cloaked", "Slipstream", "Flash", "Titan", "Core", "Avalanche", "Thunder", "Panzer", "PENETRATOR", "Fatal1ty", "Pro", "Death", "Dread", "COMBAT", "Z", "OPS", "SPECIAL", "Commando", "Marine", "Red", "Gamer", "Trinity", "Unity", "Zero", "Steel", "Havoc", "Apocalypse", "Tiger", "Sabre", "Sword", "Mace", "Axe", "Spear", "Terminator", "Alien", "Dragon", "Warrior", "Warlord", "Kingmaker", "ESport", "Soldier", "Galactic", "Generation", "Mod", "Victory", "Vengeance", "Secret", "Harmageddon", "Airborne", "Professional", "Mortar", "Tomahawk", "Scimitar", "Rapier", "Lance", "Gutter"} | |
fix = {"X", "Ultra", "Extreme", "Turbo", "Xtreme", "Z", "Pro", "Gold", "Silver", "Platinum", "Blu"} | |
prefix = {"True", "Super", "Rapid", "Infra", "Laser", "Tri", "Quadra", "Hexa", "Giga", "Mega", "Penta", "Kill", "Phase"} | |
suffix = {"Edition", "3D", "G", "ZX", "Q", "Lite", "OC", "I", "II", "III", "IV", "V", "Elite", "Fi", "Ace"} | |
def _manufacturer(res): | |
res.text = random.choice(manufacturers) + " " | |
res.ws = False | |
return res | |
def _prefix(res): | |
if res.ws: | |
res.text += " " | |
res.text += random.choice(list(fix | prefix)) + random.choice(["-", "", " "]) | |
res.ws = False | |
return res | |
def _suffix(res): | |
res.text += random.choice(["-", "", " "]) + random.choice(list(fix | suffix)) | |
res.ws = True | |
return res | |
def _noun(res): | |
if res.ws: | |
res.text += " " | |
n = "" | |
if not hasattr(res, "picked_nouns"): | |
n = random.choice(list(words)) | |
res.picked_nouns = set(n) | |
else: | |
n = random.choice(list(words - res.picked_nouns)) | |
res.picked_nouns.add(n) | |
res.text += n | |
res.ws = True | |
return res | |
def _end(res): | |
if res.ws: | |
res.text += " " | |
res.text += "".join(random.sample(string.ascii_uppercase, random.randint(1, 3))) | |
res.text += "".join(random.sample(string.digits, random.randint(1, 4))) | |
return res | |
class itval: | |
def __init__(self, a, b): | |
self.a = a | |
self.b = b | |
def __contains__(self, v): | |
return v >= self.a and v <= self.b | |
_state_table = { | |
_manufacturer: {itval(0.0, 0.33): _prefix, itval(0.33, 1.0): _noun}, | |
_noun: {itval(0.0, 0.33): _suffix, itval(0.33, 0.43): _noun, itval(0.43, 0.76): _prefix, itval(0.76, 1.0): _end}, | |
_suffix: {itval(0.0, 0.23): _noun, itval(0.23, 0.40): _prefix, itval(0.40, 1.0): _end}, | |
_prefix: {itval(0.0, 1.0): _noun}, | |
_end: {} | |
} | |
def _run_states(): | |
"""Run the state machine, and generate an output. | |
""" | |
res = SimpleNamespace() | |
res.text = "" | |
res.ws = False | |
s = _manufacturer | |
next_states = {1.0: "Bogus"} | |
while next_states != {}: | |
res = s(res) | |
next_states = _state_table[s] | |
# Decide next state. | |
x = random.uniform(0.0, 1.0) | |
for k,v in next_states.items(): | |
if x in k: | |
s = v | |
break | |
continue | |
return res.text | |
def generate(n): | |
"""Return a generator item for up to n names.""" | |
for i in range(0, n): | |
yield _run_states() | |
def main(argv): | |
parser = argparse.ArgumentParser(description="Generate cool Gam3r names.") | |
parser.add_argument("count", metavar="COUNT", type=int, help="How many names to generate.") | |
args = parser.parse_args(argv) | |
print("\n".join(generate(args.count))) | |
if __name__ == '__main__': | |
main(sys.argv[1:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's some fine examples of output:
MSI KILLER Ultra ZGeneration IC8
Gigabyte SuperSlayer OJ2137
ASrock XSoldier 3D FS9
ASrock Slayer X NVI16
BFG X KILLER J96
Gigabyte Galactic Pro FLH27
ASrock Terminator Gamer-3D F2
BFG Mace Xtreme Steel IF42