Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1.  
  2. import random
  3. import time
  4.  
  5. class Prizebox:
  6.  
  7. def __init__(self, kind, label, contents, big_prize=False, open=False):
  8. self.kind = kind
  9. self.label = label
  10. self.contents = contents
  11. self.big_prize = big_prize
  12. self.open = open
  13.  
  14.  
  15. class Stage:
  16.  
  17. def __init__(self, name, *args): #args will be Prizebox objects
  18. self.name = name
  19. self.spots = list(args)
  20.  
  21.  
  22. def kinds(self):
  23. k = [self.spots[i].kind for i in range(0, len(self.spots))]
  24. return k
  25.  
  26.  
  27. def show_goat(self, prize):
  28. #make list of just 'goats'
  29. g = []
  30. if prize.big_prize:
  31. g = [item for item in self.spots if item.label != prize.label]
  32. random.shuffle(g)
  33. else:
  34. g = [item for item in self.spots if item.label != prize.label and not item.big_prize]
  35. return g
  36.  
  37.  
  38.  
  39.  
  40. def get_choice(options):
  41. if options == None: return False
  42. print(', '.join(options))
  43. c = input('\n')
  44. if c not in (options):
  45. return False
  46. else:
  47. return c
  48.  
  49. def get_choice2(options):
  50. return ''
  51.  
  52.  
  53.  
  54.  
  55. """
  56. Set up the prizes and the stage
  57. """
  58. door1 = Prizebox('door', 'Door #1', 'golf cart', True)
  59. door2 = Prizebox('door', 'Door #2', 'box of diapers')
  60. chest = Prizebox('treasure chest', 'the treasure chest', '$5 bill')
  61. box_list = [door1, door2, chest]
  62. random.shuffle(box_list)
  63. stage = Stage('Let\'s Make a Deal!', *box_list)
  64.  
  65. """
  66. Get the contestant's initial choice
  67. """
  68. print('The \"' + stage.name + '\" stage has on it these %d items:' % (len(stage.spots)))
  69. print(', '.join(stage.kinds()))
  70.  
  71. print('\nWhich item would you like to choose?')
  72. print('-'*35)
  73. choices = [stage.spots[i].label for i in range(0, len(stage.spots))]
  74. while not get_choice(None):
  75. first_choice = get_choice(choices)
  76. if first_choice: break
  77. print('\nAwesome, you chose ' + first_choice + '.')
  78.  
  79. """
  80. Show a door with a 'goat' level prize
  81. """
  82. for item in stage.spots:
  83. if item.label == first_choice:
  84. goat_list = stage.show_goat(item)
  85. print('\nBefore we see what\'s there, let me show you %s...\n' % (goat_list[0].label) )
  86. print(goat_list[0].contents)
  87.  
  88.  
  89. """
  90. Get the contestant's decision to stay with their choice or switch
  91. """
  92. print('\nWould you like to stay with %s or switch to %s?' % (first_choice, 'placeholder'))
  93. #what's the other door? maybe based on .closed property
  94. get_choice2()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement