Created
April 16, 2017 09:05
-
-
Save robo-corg/419de44e369164305321f706df844b54 to your computer and use it in GitHub Desktop.
Random game generator
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
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"rules = {\n", | |
" 'goal' : ['while helping your <relationship>', 'in a fixed time limit', 'with out dying', 'while staying true to yourself', 'while eventually solving a murder', 'while defeating <enemy>'],\n", | |
" 'action': ['move <thing>', 'eat <thing>', 'shoot <enemy>', 'fly around <place>', 'visit <place>', 'destroy <thing>', 'save <thing>'],\n", | |
" 'place': ['the sky', 'the city', 'space', 'america', 'the past', 'a really small house', '<relationship>\\'s house', 'a creepy <creepyplace>'],\n", | |
" 'creepyplace': ['basement', 'attic', 'haunted house', 'abandoned hospital'],\n", | |
" 'thing': ['blocks', 'rocks', 'pizza', 'pepsi', 'hotdogs', 'corgis', 'dogs', 'baseballs', 'pie', 'trees'],\n", | |
" 'enemy': ['bears', 'ghosts', 'aliens', 'evil wizards', 'goblins'],\n", | |
" 'relationship': ['dad', 'mom', 'son', 'daughter', 'dog', 'cat', 'grandpa'],\n", | |
" 'reason': ['your <relationship> is in league with <enemy>', 'you really like <thing>', '<enemy> are actually good guys']\n", | |
"}\n", | |
"\n", | |
"game_design = 'You must <action> <goal> but don\\'t <action> because <reason>'" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"\"You must move pie while defeating aliens but don't move pizza because evil wizards are actually good guys\"" | |
] | |
}, | |
"execution_count": 2, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"import random\n", | |
"\n", | |
"new_design = game_design\n", | |
"\n", | |
"for n in range(100): \n", | |
" for rule_name, rule_values in rules.items():\n", | |
" new_design = new_design.replace('<{}>'.format(rule_name), random.choice(rule_values), 1)\n", | |
" \n", | |
" if '<' not in new_design:\n", | |
" break\n", | |
"\n", | |
"new_design" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Best Ones\n", | |
"\n", | |
"You must move corgis while defeating ghosts but don't shoot bears because evil wizards are actually good guys\n", | |
"\n", | |
"You must shoot aliens in a fixed time limit but don't fly around the sky because ghosts are actually good guys\n", | |
"\n", | |
"You must shoot goblins while helping your grandpa but don't destroy rocks because you really like rocks\n", | |
"\n", | |
"You must save corgis while helping your dog but don't visit the past because you really like corgis" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.6.1" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment