Created
May 29, 2023 20:29
-
-
Save BDF/a7f0b36c6f3034a2a171aba0d837e481 to your computer and use it in GitHub Desktop.
Playing with Python Dice Roller
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
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