Example #1
0
    def __init__(self):
        self.screen = pygame.display.get_surface()
        self.screen_rect = self.screen.get_rect()
        self.clock = pygame.time.Clock()
        self.fps = FPS

        self.keys = pygame.key.get_pressed()

        self.data = {
            'J': array([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0,
                                                                   1]]),
            'UA': array([[1, 0], [0, 1]])
        }

        self.stages = [
            StartStage,
            AliceStage,
            BobStage,
            # AliceDecides,
            # ShowResult
        ]

        self.stage_index = 0

        self.quit = False
        self.back = False

        cx, cy = self.screen_rect.center
        # self.CircuitDisplay = CircuitDisplay(self.data)

        self.BackButton = BackButton()
        self.CircuitButton = CircuitButton()
Example #2
0
    def __init__(self, data):
        self.data = data

        self.screen = pygame.display.get_surface()
        self.screen_rect = self.screen.get_rect()
        self.clock = pygame.time.Clock()
        self.fps = FPS

        self.keys = pygame.key.get_pressed()

        cx, cy = self.screen_rect.center

        # display objects
        self.Celebration = Celebration(
            (cx, Celebration.height/2), self.data)
        self.Message = Message((cx, cy + Message.height/4), self.data)

        # buttons
        self.ConfirmButton = ConfirmButton()
        self.BackButton = BackButton()
        self.CircuitButton = CircuitButton()

        self.tutorial_on = False
        # self.TutorialBlocks = [TutorialBlock()]

        self.next_stage = False
        self.quit = False
        self.back = False
        self.show_circuit = False
Example #3
0
    def __init__(self, data):
        self.data = data

        self.screen = pygame.display.get_surface()
        self.screen_rect = self.screen.get_rect()
        self.clock = pygame.time.Clock()
        self.fps = FPS

        self.keys = pygame.key.get_pressed()

        cx, cy = self.screen_rect.center

        # display objects
        self.Message = Message((cx, cy))

        # buttons
        self.YesButton = YesButton()
        self.NoButton = NoButton()
        self.BackButton = BackButton()
        self.CircuitButton = CircuitButton()

        self.tutorial_on = False
        # self.TutorialBlocks = [TutorialBlock()]

        self.next_stage = False
        self.quit = False
        self.back = False
        self.show_circuit = False
        self.real_qc = None
Example #4
0
    def __init__(self):

        self.screen = pygame.display.get_surface()
        self.screen_rect = self.screen.get_rect()
        self.clock = pygame.time.Clock()
        self.fps = FPS

        self.keys = pygame.key.get_pressed()

        self.data = {'BallProbDist': [1/3, 1/3, 1/3],
                     'BobChosenDoor': -1,
                     'AliceOpenedDoor': -1,
                     'SwitchProbDist': [1, 0],
                     'Measurement': 0.0,
                     'WinRate': [0, 1]}

        self.stages = [AliceArrangesBalls,
                       BobChoosesDoor,
                       AliceOpensDoor,
                       BobSwitchesDoor,
                       RunOnRealQC,
                       ShowResult,]

        self.stage_index = 0

        self.quit = False
        self.back = False
        
        self.Loader = Loader()

        self.CircuitDisplay = CircuitDisplay(self.data)
        
        self.ConfirmButton = ConfirmButton()
        self.BackButton = BackButton()
        self.CircuitButton = CircuitButton()
Example #5
0
    def __init__(self, data):
        self.data = data
        self.screen = pygame.display.get_surface()
        self.screen_rect = self.screen.get_rect()
        self.clock = pygame.time.Clock()
        self.fps = FPS

        self.keys = pygame.key.get_pressed()

        self.checked_db = None

        cx, cy = self.screen_rect.center

        self.DoorBobs = [
            DoorBob((cx / 2, cy), self.data),
            DoorBob((cx, cy), self.data),
            DoorBob((3 * cx / 2, cy), self.data)
        ]

        self.ConfirmButton = ConfirmButton()
        self.CircuitButton = CircuitButton()
        self.BackButton = BackButton()

        self.tutorial_on = False
        # self.TutorialBlocks = [TutorialBlock()]

        self.next_stage = False
        self.quit = False
        self.back = False
        self.show_circuit = False
Example #6
0
    def __init__(self, data):
        self.data = data
        self.screen = pygame.display.get_surface()
        self.screen_rect = self.screen.get_rect()
        self.clock = pygame.time.Clock()
        self.fps = FPS

        self.keys = pygame.key.get_pressed()

        self.checked_da = None

        cx, cy = self.screen_rect.center

        self.DoorBars = [
            DoorBar((cx / 2, cy), self.data['BallProbDist'][0]),
            DoorBar((cx, cy), self.data['BallProbDist'][1]),
            DoorBar((3 * cx / 2, cy), self.data['BallProbDist'][2])
        ]

        self.DoorAlices = [
            DoorAlice((cx / 2, cy), self.data),
            DoorAlice((cx, cy), self.data),
            DoorAlice((3 * cx / 2, cy), self.data)
        ]

        self.DoorAlices[self.data['BobChosenDoor']].chosen = True

        # the door with smaller prob cannot be opened!
        prob = None
        index = None
        for i in range(3):
            if not self.DoorAlices[i].chosen:
                if prob == None and index == None:
                    prob = self.data['BallProbDist'][i]
                    index = i
                else:
                    this_prob = self.data['BallProbDist'][i]
                    if prob > this_prob:
                        self.DoorAlices[index].lock = True
                    elif prob == this_prob:
                        pass
                    else:
                        self.DoorAlices[i].lock = True

        self.ConfirmButton = ConfirmButton()
        self.CircuitButton = CircuitButton()
        self.BackButton = BackButton()

        self.tutorial_on = False
        # self.TutorialBlocks = [TutorialBlock()]

        self.next_stage = False
        self.quit = False
        self.back = False
        self.show_circuit = False
Example #7
0
    def __init__(self, data):
        """
        Get a reference to the screen (created in main); define necessary
        attributes; and create our thing.
        """
        self.data = data

        self.screen = pygame.display.get_surface()
        self.screen_rect = self.screen.get_rect()
        self.clock = pygame.time.Clock()
        self.fps = FPS

        self.keys = pygame.key.get_pressed()

        self.dragged_k = None
        self.checked_cb = None

        cx, cy = self.screen_rect.center
        self.alice = Alice((cx - 100, 1.2 * cy))
        self.bob = Bob((cx + 100, 1.2 * cy))
        self.Knobs = [Knob((cx / 2, 0.5 * cy), 0)]

        self.caption = Caption((cx, 0.5 * cy))

        # self.Doors = [Door((cx / 2, cy)),
        #               Door((cx, cy)),
        #               Door((3 * cx / 2, cy))]
        #
        # self.CheckBoxes = [CheckBox((cx / 2, cy + Door.height / 2 + 20)),
        #                    CheckBox((cx, cy + Door.height / 2 + 20)),
        #                    CheckBox((3 * cx / 2, cy + Door.height / 2 + 20))]
        #
        # self.Ball = Ball([(cx / 2, cy - Door.height / 4),
        #                   (cx, cy - Door.height / 4),
        #                   (3 * cx / 2, cy - Door.height / 4)],
        #                  self.data['BallProbDist'])

        self.ConfirmButton = ConfirmButton()
        self.BackButton = BackButton()
        self.CircuitButton = CircuitButton()

        self.tutorial_on = False
        # self.TutorialBlocks = [TutorialBlock()]

        self.next_stage = False
        self.quit = False
        self.back = False
        self.show_circuit = False
Example #8
0
    def __init__(self, data):
        self.data = data

        self.screen = pygame.display.get_surface()
        self.screen_rect = self.screen.get_rect()
        self.clock = pygame.time.Clock()
        self.fps = FPS

        self.keys = pygame.key.get_pressed()

        self.dragged_db = None
        self.checked_cb = None

        cx, cy = self.screen_rect.center
        self.DoorBars = [
            DoorBar((cx / 2, cy), self.data['BallProbDist'][0]),
            DoorBar((cx, cy), self.data['BallProbDist'][1]),
            DoorBar((3 * cx / 2, cy), self.data['BallProbDist'][2])
        ]

        self.Doors = [
            Door((cx / 2, cy)),
            Door((cx, cy)),
            Door((3 * cx / 2, cy))
        ]

        self.CheckBoxes = [
            CheckBox((cx / 2, cy + Door.height / 2 + 20)),
            CheckBox((cx, cy + Door.height / 2 + 20)),
            CheckBox((3 * cx / 2, cy + Door.height / 2 + 20))
        ]

        self.Ball = Ball([(cx / 2, cy - Door.height / 4),
                          (cx, cy - Door.height / 4),
                          (3 * cx / 2, cy - Door.height / 4)],
                         self.data['BallProbDist'])

        self.ConfirmButton = ConfirmButton()
        self.BackButton = BackButton()
        self.CircuitButton = CircuitButton()

        self.tutorial_on = False
        #self.TutorialBlocks = [TutorialBlock()]

        self.next_stage = False
        self.quit = False
        self.back = False
        self.show_circuit = False
Example #9
0
    def __init__(self, data):

        self.data = data

        self.screen = pygame.display.get_surface()
        self.screen_rect = self.screen.get_rect()
        self.clock = pygame.time.Clock()
        self.fps = FPS

        self.keys = pygame.key.get_pressed()

        self.dragged_k = None
        self.checked_cb = None

        cx, cy = self.screen_rect.center

        self.Officer = Officer((5 * cx / 3, cy - 100))
        self.Phi = Phi((100, cy + 60))
        self.Theta = Theta((100, cy - 60))
        self.caption = Caption((cx, 0.5 * cy))

        self.Knobs = [
            Knob((50, cy - 60), np.pi / 2),  # theta
            Knob((50, cy + 60), 0)
        ]  # phi

        self.GBButtons = [
            GBButton((cx + 75, cy + 150), self.Knobs[0].angle, 'red', 'GOOD!'),
            GBButton((cx - 100, cy + 150), self.Knobs[0].angle, 'blue', 'BAD!')
        ]

        self.ConfirmButton = ConfirmButton()
        self.BackButton = BackButton()
        self.CircuitButton = CircuitButton()

        self.next_stage = False
        self.quit = False
        self.back = False
        self.show_circuit = False
Example #10
0
    def __init__(self, data):

        self.data = data
        self.Alice = self.data['AliceOpenedDoor']
        self.screen = pygame.display.get_surface()
        self.screen_rect = self.screen.get_rect()
        self.clock = pygame.time.Clock()
        self.fps = FPS

        self.keys = pygame.key.get_pressed()

        self.dragged_db = None
        self.checked_cb = None

        cx, cy = self.screen_rect.center

        self.DoorPos = [(cx / 2, cy), (cx, cy), (1.5 * cx, cy)]

        self.BobPos = [(cx / 2 - Door.width * 4 // 3, cy),
                       (cx - Door.width * 4 // 3, cy),
                       (3 * cx / 2 - Door.width * 4 // 3, cy)]

        # swap if bob did not choose door 00, to ensure |0> is bob's initial choice
        if self.data['BobChosenDoor'] != 0:
            choice = self.data['BobChosenDoor']
            self.DoorPos[choice], self.DoorPos[0] = self.DoorPos[
                0], self.DoorPos[choice]
            self.BobPos[choice], self.BobPos[0] = self.BobPos[0], self.BobPos[
                choice]

        # swap Alice as well if Alice choosed 0
        if self.Alice == 0:
            self.Alice = choice

        #remove Alice's choice from Bob's image
        self.BobPos.pop(self.Alice)

        #remove and take out the pos of Alice's Choice
        self.OpenedDoorPos = self.DoorPos.pop(self.Alice)

        self.DoorBars = [
            DoorBarBob(self.DoorPos[0], self.data['SwitchProbDist'][0]),
            DoorBarBob(self.DoorPos[1], self.data['SwitchProbDist'][1])
        ]

        self.Doors = [Door(self.DoorPos[0]), Door(self.DoorPos[1])]

        self.BobImage = BobImage(self.BobPos, self.data['SwitchProbDist'])

        self.OpenedDoor = OpenedDoor(self.OpenedDoorPos)

        self.ConfirmButton = ConfirmButton()
        self.BackButton = BackButton()
        self.CircuitButton = CircuitButton()

        self.tutorial_on = False
        #self.TutorialBlocks = [TutorialBlock()]

        self.next_stage = False
        self.quit = False
        self.back = False
        self.show_circuit = False