Advertisement
Guest User

hada_madrina_ratios

a guest
Jan 27th, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. import collections
  2. import random
  3.  
  4. # 1D6
  5. dice = [1, 2, 3, 4, 5, 6]
  6.  
  7. # rolls a 3D6
  8. roll = lambda x: sum([random.choice(dice) for _ in range(x)])
  9.  
  10. # roll 1000 times a roll 3D6
  11. rolls = collections.Counter([roll(3) for _ in range(1000)])
  12.  
  13. # ratio of success and fails
  14. success = sum(times for face, times in rolls.items() if face < 12)
  15. fails = sum(times for face, times in rolls.items() if face >= 12)
  16.  
  17. print(f'The chance of success is: {success / 10:.02f}')
  18. print(f'The chance of fails is: {fails / 10:.02f}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement