Skip to content

Instantly share code, notes, and snippets.

@Kodiologist
Created August 25, 2019 14:50
Show Gist options
  • Save Kodiologist/29e9d2da31f33fc0c71a068f5d3ab9ac to your computer and use it in GitHub Desktop.
Save Kodiologist/29e9d2da31f33fc0c71a068f5d3ab9ac to your computer and use it in GitHub Desktop.
Madey Upy Namey Emulator (MUNE)
#!/usr/bin/env python3
"""
A simple implementation of the Madey Upy Namey Emulator (MUNE;
https://homebrewery.naturalcrit.com/share/rkmo0t9k4Q ).
Usage examples:
$ python3 -i mune.py
>>> oracle()
('Yes.', None) # The second element is an intervention, if any.
>>> oracle(bias = 1) # Advantage
('Yes, and...', None)
>>> oracle(bias = 0) # Disadvantage
('No, but...', None)
>>> attitude() # Also accepts a bias.
([2], 'Friendly')
>>> twene()
([8], 'Wild negative')
This program is in the public domain.
"""
import random
INTERVENTION_THRESHOLD = 3
intervention_points = 0
def roll(bias, options):
dice = [random.randrange(len(options))
for _ in range(1 + (bias is not None))]
result = options[(max if bias else min)(dice)]
return dice, result
def oracle(bias = None):
options = [
'No, and...', 'No.', 'No, but...',
'Yes, but...', 'Yes.', 'Yes, and...']
dice, result = roll(bias, options)
global intervention_points
intervention_points += sum(n == len(options) - 1 for n in dice)
intervention = None
if intervention_points >= INTERVENTION_THRESHOLD:
intervention = intervene()
intervention_points -= INTERVENTION_THRESHOLD
return (result, intervention)
def intervene():
return roll(None, [
'New entity', 'Entity positive', 'Entity negative',
'Advance plot', 'Regress plot', 'Wild'])
def attitude(bias = None):
return roll(bias, [
'Hostile', 'Neutral', 'Friendly'])
def twene():
return roll(None, [
'Increase simple element', 'Decrease simple element'
'Add simple element', 'Remove simple element',
'Increase major element', 'Decrease major element',
'Add major element', 'Remove major element',
'Wild positive', 'Wild negative'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment