Guest User

Untitled

a guest
Oct 25th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.20 KB | None | 0 0
  1. from random import randint
  2. def play_razzle():
  3.     points = {42:1.5, 15:1.5, 41:1.5, 14:1.5, 8:10, 45:5, 13:5, 46:8, 9:8, 48:10, 10:5, 47:8, 11:5, 44:5, 12:5, 43:5, 40:.5, 17:.5, 39:.5, 16:.5}
  4.     score = 0
  5.     total_spent = 0
  6.     num_rolls = 0
  7.     cost = 1
  8.     rolls = []
  9.     while score < 10:
  10.             total_spent += cost
  11.             roll = 0
  12.             num_rolls += 1
  13.             for r in range(8):
  14.                     roll += randint(1,6)
  15.             try:
  16.                     worth = points[roll]
  17.             except:
  18.                     worth = 0
  19.             rolls.append(roll)
  20.             if roll != 29:
  21.                     print "Roll Number: %s" %num_rolls
  22.                     print "Total Spent: %s" %total_spent
  23.                     print "Roll: %s" %roll
  24.                     print "Roll Worth: %s" %worth
  25.                     print "Score: %s" %score
  26.                     score += worth
  27.             elif roll == 29:
  28.                     print "Rolled a 29! Doubling cost per roll..."
  29.                     cost += cost*2
  30.             if score >= 10:
  31.                     print "Congratulations, you win after %s rolls and $%s spent!" %(num_rolls, total_spent)
  32.                     return rolls
Advertisement
Add Comment
Please, Sign In to add comment