Skip to content

Instantly share code, notes, and snippets.

@gngdb gngdb/d12.py

Created Apr 9, 2020
Embed
What would you like to do?
Pure Python Gumbel Dice
import dice
print(dice.roll(12))
import dice
print(dice.roll(20))
import dice
print(dice.roll(6))
import math
from random import random
def gumbel(eps=1e-6):
U = random()
return -math.log(-math.log(U+eps)+eps)
def roll(sides):
G = [gumbel() for i in range(sides)]
return [i for g,i in zip(G, range(sides)) if g == max(G)][0]+1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.