Skip to content

Instantly share code, notes, and snippets.

@BDF
Created May 29, 2023 20:29
Show Gist options
  • Save BDF/a7f0b36c6f3034a2a171aba0d837e481 to your computer and use it in GitHub Desktop.
Save BDF/a7f0b36c6f3034a2a171aba0d837e481 to your computer and use it in GitHub Desktop.
Playing with Python Dice Roller
from random import randint
def main(debug=0):
if debug == 1:
results = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
for i in range(0, 5000):
results[rolldice(2, 6)] += 1
for i in range(0, 26):
print(int(i + 1), ":", results[i])
# print("Standard 2D10:",RollDice(2,10))
# print("3D6 minimum 9:",RollDice(3,6,16))
def rolldice(number=1, faces=6, min=0):
value = -1
while value < min:
value = -1
for i in range(0, number):
value += randint(1, faces)
# print ("Value:",value)
return value
main(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment