示例#1
0
 def __init__(self, parent=None):
     super(MainWindow, self).__init__()
     QtWidgets.QMainWindow.__init__(self)
     #Importando el archivo .css
     instructions = Instructions()
     with open("MainWindow.css") as f:
         self.setStyleSheet(f.read())
     self.setupUi(self)
     self.setWindowIcon(QIcon("logo.png"))
     self.instructions = QLabelClickable("Instrucciones...")
     self.instructions.clicked.connect(lambda: instructions.show())
     self.layout.addWidget(self.instructions)
     #Lo que va a aparecer en cada QPlainText cuando esté vacío
     self.array = ""
     self.roads = ""
     self.edge_labels = {}
     self.characters.setTabStopWidth(
         self.characters.fontMetrics().width(" ") * 10)
     self.characters.setPlaceholderText(
         "Ingrese vértices, aristas y caracteristicas.")
     self.root_node.setPlaceholderText("Nodo Origen")
     self.last_node.setPlaceholderText("Nodo Destino")
     self.load_file.clicked.connect(self.loadFile)
     self.create_map.clicked.connect(self.passToOpen)
     self.create_table.clicked.connect(self.openTable)
     #self.converter()
     self.setFocus()
示例#2
0
 def __init__(self):
     self.instructions_ = Instructions.Instructions("instructions_pl.txt",
                                                    "Instrukcje gry")
     self.instructions_.show_instructions()
     self.chess_engine_ = ChessEngine.ChessEngine(True)
     self.gui_ = GUI.GUI()
     self.converter_ = ChessConverter.ChessConverter()
示例#3
0
    def listen(self):
        instructions = Instructions.Instructions("instructions_pl.txt",
                                                 "instrukcje gry")

        try:
            self.move_ = ''
            os.system('python run_sarmata.py')
            f = open("result.txt", "r")
            self.message_ = f.read()
            if self.message_ == "otwórz instrukcje" or self.message_ == "pokaż instrukcje":
                instructions.show_instructions()
            elif self.message_ == "poddaję się" or self.message_ == "poddaj się" \
                    or self.message_ == "zakończ grę" or self.message_ == "koniec gry":
                sys.exit(1)
            elif self.message_ == "repeat":
                winsound.PlaySound("repeat_pl.wav", winsound.SND_FILENAME)
                self.listen()
            elif self.message_ == "pokaż dostępne ruchy" or self.message_ == "pokaż możliwe ruchy":
                winsound.PlaySound("ask_of_figure_pl.wav",
                                   winsound.SND_FILENAME)
                self.checking_ = True
                self.listen()
            elif self.checking_:
                self.move_ = self.converter_.convert_pos(c=self.message_)
            else:
                self.move_ = self.converter_.convert(c=self.message_)
            f.close()

        except:
            if self.message_ == "poddaję się" or self.message_ == "poddaj się" \
                    or self.message_ == "zakończ grę" or self.message_ == "koniec gry" or self.message_ == "koniec":
                sys.exit(1)
示例#4
0
 def event(self, event):
     if event.type == PG.MOUSEBUTTONDOWN:
         if self.selected[0]:
             G.Globals.STATE = StoryBoard.StoryBoard(
                 "story_texts/intro.txt", self.images)
         if self.selected[1]:
             G.Globals.STATE = Instructions.Instructions()
         if self.selected[2]:
             G.Globals.STATE = Options.Options()
         if self.selected[3]:
             G.Globals.STATE = Score.Score()
         if self.selected[4]:
             G.Globals.RUNNING = False
def RUN():
    global SignalValue
    FPSclock = pygame.time.Clock()
    FPSclock.tick(FPS)
    StimList = LoadStim(LanuageNumber)
    BaseStim = LoadBaseStim(LanuageNumber)
    mRT = []
    mAcc = []
    while True:
        [ConsentScreen(i) for i in range(2)]
        [Instructions(i) for i in range(28)]
        for block in range(Blocks):
            RT              = []
            Acc             = []
            RspList         = []
            AngleList       = []
            CndList         = []
            MouseList       = []
            SignalContrast  = []
            ContrastListN   = []
            MovementOnset   = []
            TimeInMotion    = []
            for trial, contrastN in cnd_list_contrasts(Trials,blockN=block):
                if trial == 111:
                    nRT = np.asarray(RT); nAcc = np.asarray(Acc)
                    mRT.append( np.mean( np.abs( nRT[nRT > -Max_Stim_Time] ) ) / 1000 ) # Mean RT excluding Timeouts
                    mAcc.append( np.mean( nAcc ) * 100 )
                    
                    SaveDict                            = OrderedDict()
                    SaveDict['NativeLangNumber']        = [NativeNumber] * len(RT)
                    SaveDict['LanuageNumber']           = [LanuageNumber] * len(RT)
                    SaveDict['SessionNumber']           = [SessionNumber] * len(RT)
                    SaveDict['Block']                   = [block]*len(RT)
                    SaveDict['TrialNum']                = list(range(1,len(RT)+1))
                    SaveDict['ConditionNumber']         = CndList
                    SaveDict['Response']                = RspList
                    SaveDict['Accuracy']                = Acc
                    SaveDict['RT']                      = RT
                    SaveDict['MovementOnsetTime']       = MovementOnset
                    SaveDict['TimeInMotion']            = TimeInMotion
                    SaveDict['SignalContrast']          = SignalContrast
                    SaveDict['SignalContrastNumber']    = ContrastListN

                    SaveDict['StimDisplayTime']         = [Stim_Display_Time] * len(RT)
                    SaveDict['MaskTime']                = [Mask_Time] * len(RT)
                    SaveDict['MaxResponseTime']         = [Max_Stim_Time] * len(RT)
                    
                    SaveDict['MousePositionXY']         = MouseList
                    SaveDict['MouseAngle']              = AngleList
                    SaveDict['WheelOrder']              = [WheelOrder] * len(RT)
                    SaveDict['NoiseMuSigma']            = zip([NoiseMu], [NoiseSigma]) * len(RT)
                    
                    SaveDict['ParticipantID']           = [ParticipantID]*len(RT)
                    SaveDict['LanuageTested']           = [PartPrefix] * len(RT)
                    SaveDict['SessionTested']           = [SessionLetter] * len(RT)
                    SaveDict['NativeLanuage']           = [NativeLanuage] * len(RT)
                    SaveDict['Date']                    = [Date] * len(RT)
                    SaveDict['ResponseDevice']          = [Device] * len(RT)
                    
                    Save(block, SaveDict)
                    Feedback( block, mRT, mAcc )

                    if block == 0:
                        SignalValue = int(round(np.mean(SignalContrast[-30:]))) # Changed to -30 rather than -20 during piloting
                        ConstantSignalValue = SignalValue
                    
                else:
                    if block > 0:
                        # 3-x-1 Design
                        SignalValue = range(ConstantSignalValue-NContrastLevels+2, ConstantSignalValue+2)[contrastN] 
                    else:
                        contrastN = 0
                    pre_trial_screen()
                    DrawNoisyStim( trial, BaseStim, Signal=SignalValue, mu=NoiseMu, sigma=NoiseSigma, UPDATE=True )
                    wait_time(Stim_Display_Time) # Non-Response Interval
                    DisplayMask(MaskD, FigSize)
                    wait_time(Mask_Time) # Mask Display
                    DrawWheel(LoadedStimList=StimList) # RTI begins
                    if JOYSTICK == []:
                        Signal = MouseResponse( trial, block, InnerRadius, RT, Acc, RspList, AngleList, MouseList, Signal=SignalValue, MouseStart=MovementOnset, MotionRT=TimeInMotion )
                    else:
                        JoystickResponse( trial, block, InnerRadius, RT, Acc, RspList, AngleList, MouseList )

                    CndList.append( trial )
                    SignalContrast.append(SignalValue)
                    ContrastListN.append( contrastN )
                    SignalValue = Signal
 def showInstructions(self):
     Instructions(self)
BetweenText = []
txt = 'This is the end of the first round of tasks. There will be two more rounds similar to this one. \n\n'
#txt += 'In the "DOES IT HAVE MEANING?" task, please respond as quickly as possible. '
#txt += '\n\nThe Q key will always correspond to "' + responses[0] 
#txt += '" and the P key to "' + responses[1] + '". Make sure your index fingers rest on these keys.\n\n'
txt += 'Take a short break if you want to. Press any key to continue to the next block of the experiment.'
BetweenText.append(txt)
txt = 'This is the end of the second round of tasks. There will be one more round similar to this one. \n\n'
#txt += 'In the "DOES IT HAVE MEANING?" task, please respond as quickly as possible. '
#txt += '\n\nThe Q key will always correspond to "' + responses[0] 
#txt += '" and the P key to "' + responses[1] + '". Make sure your index fingers rest on these keys.\n\n'
txt += 'Take a short break if you want to. Press any key to continue to the next block of the experiment.'
BetweenText.append(txt)

instr = Instructions.Instructions(myWin,responses)
instr.Run()

for tsk in range(3):
    if tsk == 1:
        # priming
        instructions.setText(ImageReelText)
        instructions.draw()
        myWin.flip()
        event.waitKeys()
        myWin.flip()
        #core.wait(interTaskTime-.5)
        #myWin.flip()
        core.wait(0.5)
        task = ImageReelTask.Task(myWin,"Files/images/" + imageFolders[taskOrder[tsk]-1])
    else:
示例#8
0
def run_Tutorial(window, competitive):
    '''
    Runs all elements of the tutorial, including gameplay
    '''

    #  Setup___________
    event.Mouse(visible=False)
    savePath = os.path.expanduser('~') + '/Desktop/Temp'  # where to save data
    eventRecorder = Data_Handler(
        savePath)  # Data_Handler to record events of active tasks
    eventRecorder.Competitive = competitive

    # configure eventRecorder with file columns
    Mpacket = {
        'Session': 0,
        'SubjectID': "Tutorial",
        'Run': 0,
        'Game': 'Single Player',
        'Trial': 0,
        'P2_ID': 0
    }

    eventRecorder.ConfigureDataHandlerGameInformation(Mpacket)

    # Frequently used images
    aspectRatio = float(window.size[1]) / float(window.size[0])

    fixation = visual.TextStim(
        win=window,
        text='+',
        color='black',
    )

    # balloon for single player trials
    b1 = balloon(window,
                 0,
                 os.getcwd() + '/Resources',
                 eventRecorder=eventRecorder,
                 practice=True)

    #  BEGIN TUTORIAL_______

    # 1. welcome to task
    bButton = InstructionBox(
        window, [-0.5, 0.75],
        "Welcome to the Balloon pump game tutorial! Press the 'right arrow' key to continue.",
        True)
    bButton.buttonwait(balloons=[b1])
    window.flip()

    # 2. explain balloon and token stims
    bButton = InstructionBox(
        window, [-0.5, 0.75],
        "Pump balloons, and earn tokens, by pressing or holding the spacebar.",
        True)

    # trial setup
    b1.reset()
    b1.max = 45
    event.clearEvents()

    # Main trial loop
    while not b1.done:
        if b1.pumps < 10:
            b1.pumpAction()
            event.clearEvents()
        if b1.pumps == 10:
            if event.getKeys(['return']):
                Action = b1.cash()
                moveOn = b1.pumps == 10
                if competitive == '1':
                    b1.box.opacity = 1
                b1.outcome.setColor(u'green')

        # stop all player actions from registering and display step 5 when at 10 pumps
        if b1.pumps >= 10:
            # 5. cash in tokens
            bButton = InstructionBox(
                window, [0.55, 0.55],
                "Press the return key to cash in these tokens.", False)

        b1.update()
        for b in bButton.drawList:
            b.draw()
        window.flip()
        if b1.done:
            core.wait(2)
    event.clearEvents()

    # 6. begin single player freeplay trials
    bButton = InstructionBox(
        window, [0, 0],
        "Try a few more balloons on your own.\n\n (remember, you can hold the spacebar to pump quickly).",
        True)
    bButton.buttonwait()
    window.flip()

    # setup for trial loop
    eventRecorder.p1 = b1
    eventRecorder.p2 = None
    eventRecorder.Game = 0
    b1.practice = False  # start eventRecorder with above parameters

    # Player stops receiving new trials after at least 5 cashed in balloons and 1 popped balloon.
    count = 0
    popped = False
    window.flip()

    # trial loop
    while 1:
        # new trial
        b1.reset()
        eventRecorder.Trial += 1
        # fixation cross
        fixation.draw()
        window.flip()
        eventRecorder.RecordEvent('Fixation')
        core.wait(np.random.uniform(1, 3))
        # draw newly updated balloon
        b1.update()
        window.flip()
        eventRecorder.RecordEvent('StartPlay')
        event.clearEvents()  # clear junk
        #main trial loop
        while not b1.done:
            Action = b1.pumpAction()
            if event.getKeys(['return']):
                Action = b1.cash()
                if competitive == '1':
                    b1.box.opacity = 1
                b1.outcome.setColor(u'green')
            if Action:
                b1.update()
                window.flip()
        # 7. When player pops for the first time, explain popping mechanics.
        if b1.popped and not popped:
            bButton = InstructionBox(
                window, [0.55, 0.55],
                "Your balloon popped!\n\nWhen your balloon pops you will lose all of your tokens.",
                True)
            bButton.buttonwait(balloons=[b1])
            window.flip()
            popped = True

        else:
            core.wait(2)
        eventRecorder.RecordEvent('OutcomeScreen')
        count += 1
        if popped and count >= 5:
            break

    # 8. explain pop points. Watch range of balloons

    bButton = InstructionBox(
        window, [0, 0],
        "Every balloon can have a different pop point.\n\nLet's watch a set of balloons pump to their pop points.",
        True)
    bButton.buttonwait()
    window.flip()
    # watch balloons
    b1.practice = True
    Is = Instructions.Instructions(window, os.getcwd())
    Is.Watch(b1)

    # conigure eventRecorder
    b1.practice = False

    # alternate between in and out groups
    count = 0

    # 11. pause for questions
    bButton = InstructionBox(
        window, [0, 0],
        "If you have any questions at this point, please raise your hand and the experimenter will come to you.",
        True)
    bButton.buttonwait()

    # 15. Multiplayer introduced - explain computer and human opponents
    visual.ImageStim(
        window,
        image=os.getcwd() + '/Resources/gameimages/Computer.png',
        pos=[-0.1, 0.75],
        size=[0.2 * aspectRatio, 0.2]), visual.ImageStim(
            window,
            image=os.getcwd() + '/Resources/gameimages/SinglePlayer.png',
            pos=[0.1, 0.75],
            size=[0.2 * aspectRatio, 0.2])
    bButton = InstructionBox(
        window, [0, 0.1],
        "You will also play a multiplayer version of the Balloon pump game.\n\nIn this tutorial you will learn to play this game with a computer. In the actual experiment you will only ever play with a real participant from today's session.",
        True)
    bButton.buttonwait(extras=[
        visual.ImageStim(window,
                         image=os.getcwd() +
                         '/Resources/gameimages/Computer.png',
                         pos=[0, 0.75],
                         size=[0.2 * aspectRatio, 0.2])
    ])

    #    # p1 and p2 balloons
    b1 = balloon(window,
                 1,
                 os.getcwd() + '/Resources',
                 eventRecorder=eventRecorder,
                 practice=True)
    b2 = balloon(window,
                 2,
                 os.getcwd() + '/Resources',
                 eventRecorder=eventRecorder,
                 practice=True)

    b2.balloon.image = os.getcwd() + '/Resources/Balloons/GreyBalloonFull.png'
    b2.Token.image = os.getcwd(
    ) + '/Resources/gameImages/Token_black_other.png'

    eventRecorder.p1 = b1
    eventRecorder.p2 = b2
    window.flip()

    # 16. explain multiplayer layout.
    if competitive == '1':
        bButton = InstructionBox(
            window, [0, -0.5],
            "Multiplayer trials will look like this.\n\nYour balloon will always be on the left.",
            True)
        bButton.buttonwait(balloons=[b1, b2])
        window.flip()

        # 17. explain multiplayer rules
        bButton = InstructionBox(window, [0, -0.5],
                                 "Pump your balloon 10 times and cash in.",
                                 False)
        CP = simulated_player('AGR', b1, b2)  # create a simulated opponent

        # get ready for multiplayer trial
        bothdone = False
        b1.reset()
        b1.max = 12
        b2.reset()
        b2.max = 50
        event.clearEvents()

        # main trial loop
        b1.Ex.setAutoDraw(True)
        b2.Ex.setAutoDraw(True)
        while not bothdone:
            # let computer make moves, player only allowed to pump to 10 and cash in.
            if b1.cashed: CP.make_action()
            if b1.pumps < 10:
                b1.pumpAction()
                event.clearEvents()

            if b1.pumps == 10:
                if event.getKeys(['return']):
                    Action = b1.cash()

            if b1.done and b2.done:
                if b1.pumps > b2.pumps:
                    b1.box.opacity = 1
                    b1.outcome.setColor(u'green')
                    if b1.cashed and b2.cashed:
                        b2.Ex.setText('X')
                elif b1.pumps < b2.pumps:
                    b2.box.opacity = 1
                    b2.outcome.setColor(u'green')
                    if b1.cashed and b2.cashed:
                        b1.Ex.setText('X')
                elif b1.pumps == b2.pumps:
                    b1.Ex.setText('X')
                    b2.Ex.setText('X')
                bothdone = True
            for b in bButton.drawList:
                b.draw()

            b1.update()
            b2.update()
            window.flip()

        # 18. explain Multiplayer cashing in rules
        bButton = InstructionBox(
            window, [0, -0.5],
            "In multiplayer trials, you will receive your tokens only if you cash in ABOVE the other player. \n\nLet's practice a few more multiplayer trials now.",
            True)
        bButton.buttonwait(balloons=[b1, b2])
        window.flip()
        b1.Ex.setAutoDraw(False)
        b2.Ex.setAutoDraw(False)

        b1.practice = False
        b2.practice = False
        window.flip()
        # player 5 trials
        HasTied = False
        counter = 0
        botList = [
            'HES', 'AGR', 'NS', 'HES', 'AGR', 'NS', 'HES', 'AGR', 'NS', 'HES',
            'AGR', 'NS', 'HES', 'AGR', 'NS', 'HES', 'AGR', 'NS'
        ]
        while counter <= 6:
            CP = simulated_player(botList[counter], b1, b2)
            b1.reset()
            b2.reset()
            eventRecorder.Trial += 1

            fixation.draw()
            window.flip()
            eventRecorder.RecordEvent('Fixation')
            core.wait(1)

            bothdone = False

            b2.max = np.random.randint(
                5, 40
            )  # limit range slightly so that computer doesn't pop too often.
            eventRecorder.RecordEvent('StartPlay')
            event.clearEvents()

            if counter >= 4:
                b2.max = b1.max

            # main trial loop
            b1.Ex.setAutoDraw(True)
            b2.Ex.setAutoDraw(True)
            while not bothdone:
                b1.pumpAction()

                CP.make_action()

                if event.getKeys(['return']):
                    b1.cash()

                if event.getKeys('9'):
                    b2.cash()

                if b1.done and b2.done:
                    if b1.pumps > b2.pumps:
                        b1.box.opacity = 1
                        b1.outcome.setColor(u'green')
                        if b1.cashed and b2.cashed:
                            b2.Ex.setText('X')
                    elif b1.pumps < b2.pumps:
                        b2.box.opacity = 1
                        b2.outcome.setColor(u'green')
                        if b1.cashed and b2.cashed:
                            b1.Ex.setText('X')
                    elif b1.pumps == b2.pumps:
                        if b1.cashed and b2.cashed:
                            b1.Ex.setText('X')
                            b2.Ex.setText('X')
                    eventRecorder.RecordEvent('OutcomeScreen')
                    bothdone = True
                    counter += 1
                b1.update()
                b2.update()

                window.flip()

            core.wait(2)
            b1.Ex.setAutoDraw(False)
            b2.Ex.setAutoDraw(False)

    else:
        bButton = InstructionBox(
            window, [0, -0.5],
            "Multiplayer trials will look like this.\n\nYour balloon will always be on the left. Your balloon is completely separate from the other player's balloon. Any choices you make will have no affect on the other player's balloon.\n\nLet's practice a few more multiplayer trials now.",
            True)

        bButton.buttonwait(balloons=[b1, b2])
        window.flip()

        b1.practice = False
        b2.practice = False
        window.flip()
        counter = 0
        while counter <= 6:
            CP = simulated_player('NS', b1, b2)
            b1.reset()
            b2.reset()
            eventRecorder.Trial += 1

            fixation.draw()
            window.flip()
            eventRecorder.RecordEvent('Fixation')
            core.wait(1)

            bothdone = False

            b2.max = np.random.randint(
                5, 40
            )  # limit range slightly so that computer doesn't pop too often.
            eventRecorder.RecordEvent('StartPlay')
            event.clearEvents()

            while not bothdone:
                b1.pumpAction()

                CP.make_action()

                if event.getKeys(['return']):
                    b1.cash()
                    b1.outcome.setColor(u'green')

                if event.getKeys('9'):
                    b2.cash()
                    b2.outcome.setColor(u'green')

                if b2.cashed:
                    b2.outcome.setColor(u'green')

                if b1.done and b2.done:
                    eventRecorder.RecordEvent('OutcomeScreen')
                    bothdone = True
                    counter += 1
                b1.update()
                b2.update()

                window.flip()

            core.wait(2)

    # 21. Payment explained
    bButton = InstructionBox(
        window, [0, 0],
        "At the end of today's experiment, you will receive your earnings from ONE balloon, which will be selected at random.\n\nAll balloons, including those that popped can be selected.",
        True)
    bButton.buttonwait()

    # 22. Tutorial finished
    bButton = InstructionBox(
        window, [0, 0],
        "You have now completed the Balloon pump game tutorial!\n\nPress the next button to continue with the experiment.",
        True)
    bButton.buttonwait()