Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- def play_razzle():
- 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}
- score = 0
- total_spent = 0
- num_rolls = 0
- cost = 1
- rolls = []
- while score < 10:
- total_spent += cost
- roll = 0
- num_rolls += 1
- for r in range(8):
- roll += randint(1,6)
- try:
- worth = points[roll]
- except:
- worth = 0
- rolls.append(roll)
- if roll != 29:
- print "Roll Number: %s" %num_rolls
- print "Total Spent: %s" %total_spent
- print "Roll: %s" %roll
- print "Roll Worth: %s" %worth
- print "Score: %s" %score
- score += worth
- elif roll == 29:
- print "Rolled a 29! Doubling cost per roll..."
- cost += cost*2
- if score >= 10:
- print "Congratulations, you win after %s rolls and $%s spent!" %(num_rolls, total_spent)
- return rolls
Advertisement
Add Comment
Please, Sign In to add comment