Little project with my kid, she wanted 'fairer' dice for a board game, to remove some of the element of luck.
We wrote this little script, which basically guarantees the expected distribution.
My question is how to make this run on a website? I've never done anything with Python online. Is there a simple way to get this script working on a webpage (phone)? I already have decent web server / host.
We wrote this little script, which basically guarantees the expected distribution.
My question is how to make this run on a website? I've never done anything with Python online. Is there a simple way to get this script working on a webpage (phone)? I already have decent web server / host.
Python:
import random
outcomes = [2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 11, 11, 12]
def roll_dice(outcomes):
if outcomes:
roll = random.choice(outcomes) # Choose a random outcome
outcomes.remove(roll) # Remove the chosen roll from the list
return roll
else:
print("Dice reset")
outcomes.extend([2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 11, 11, 12])
return roll_dice(outcomes)
print("Welcome to FAIR DICE!")
input_string=""
while input_string != "q":
input_string=(input("Press Enter to roll [q - Quit]..."))
print("Result =",roll_dice(outcomes))