I have to create a simulation to repeatedly play the Monty Hall game. I've created a class. This is what I have so far. I have created the buttons, activated them, deactivated the stay and quit buttons. I have a button class that is used to activate and deactivate buttons and a graphics class to create window.
What I need to now is:
randomly choose the winning door for the startGame function
get a user to select one of the doors, set instant variable for the getOriginalDoor function
deactivate door they chose, display message indicating a losing door, wait for the user to select stay or select another door, update instant variable if they change doors, return false if they stayed, true if they did not ..all for the askSwitch function
update instant variable to keep track of wins and losses when switching and staying for the playGame function
repeatedly restart game until they press the quit button, when they press quit print the four totals of results for switch win and lose, stay win and lose for run function
Please help! I am so lost now. Any help would be greatly appreciated. Thanks so much in advance.
import sys import random as r from graphics import * from Button import * class ThreeDoor: def __init__ (self): self._createWindow() self.stayWin = 0 def _createWindow(self): self.win = GraphWin("ThreeDoor", 800, 800) self.playerWtext = Text(Point(500, 500), " ") self.playerWtext.draw(self.win) self.playerLtext = Text(Point(500, 600), " ") self.playerLtext.draw(self.win) self.playerStext = Text(Point(500, 700), " ") self.playerStext.draw(self.win) self.door1 = Button(self.win, Point(100, 200), 100, 200, "Door 1") self.door2 = Button(self.win, Point(300, 200), 100, 200, "Door 2") self.door3 = Button(self.win, Point(500, 200), 100, 200, "Door 3") self.doors = [self.door1, self.door2, self.door3] self.stay = Button(self.win, Point(700, 200), 100, 50, "Stay") self.stay.activate() self.quit = Button(self.win, Point(700, 300), 100, 50, "Quit") self.quit.activate() def __startGame(self): self.stay.deactivate() self.quit.deactivate() self.select = Text(Point(300, 500), "Select a door" ) self.select.draw(self.win) self.door1.activate() self.door2.activate() self.door3.activate() def __getOriginalDoor(self): pass def __askSwitch(self): pass def __playGame(self): self.__startGame() self.__getOriginalDoor() def run(self): self.__playGame() self.win.getMouse() self.win.close() def main(): game = ThreeDoor() game.run() if __name__ == '__main__': main()