コード例 #1
0
ファイル: train.py プロジェクト: mattdabit/Experiments
def train(pygame, screen):
    black = (0, 0, 0) 
    white = (255, 255, 255)
    textCreate(pygame,screen,"Hello! In this game you will match the pace by clicking the mouse", white)
    pygame.time.delay(5000)
    clearScreen(screen)

    textCreate(pygame,screen,"An X signals the start of a trial", white)
    pygame.time.delay(4000)
    clearScreen(screen)

    textCreate(pygame,screen,"This tone signals the end of a trial", white)
    playTone(16000, 500,2)
    pygame.time.delay(4000)
    clearScreen(screen)

    textCreate(pygame,screen,"Synchronize with the tone when it begins by clicking the mouse", white)
    pygame.time.delay(6000)
    clearScreen(screen)

    textCreate(pygame,screen,"Continue clicking the mouse at the same pace after the tone stops!", white)
    pygame.time.delay(6000)
    clearScreen(screen)

    textCreate(pygame,screen,"The pace of the tone will either be 350ms or 550ms", white)
    pygame.time.delay(6000)
    clearScreen(screen)


    textCreate(pygame,screen,"Let's practice!", white)
    pygame.time.delay(3000)
    clearScreen(screen)

    textCreate(pygame, screen,"X", white)
    pygame.time.delay(1000)

    playAudio(pygame, 0) 
    play_time = mouseClick(pygame, 25)
    playTone(16000, 500,2)
    r = rate(play_time)
    std_now = stdev(r)
    mean_now = mean(r)
    textCreate(pygame, screen, "Your average pace: %s, Your standard deviation: %s" %(mean_now, int(std_now)), white)
    pygame.time.delay(4000)

    textCreate(pygame,screen,"Let's practice at 550ms! Make sure to continue the pace!", white)
    pygame.time.delay(5000)
    clearScreen(screen)

    textCreate(pygame, screen,"X", white)
    pygame.time.delay(1000)


    playAudio(pygame, 1) 
    play_time = mouseClick(pygame, 25)
    playTone(16000, 500,2)
    r = rate(play_time)
    std_now = stdev(r)
    mean_now = mean(r)
    textCreate(pygame, screen, "Your average pace: %s, Your standard deviation: %s" %(mean_now, int(std_now)), white)
    pygame.time.delay(4000)
コード例 #2
0
ファイル: run.py プロジェクト: mattdabit/Experiments
def run():
    global trial
    global player_times
    global session
    global trial_type
    first = random.choice(ran_session)
    if first == 0:
        session = ['0']
        trial_type = ['350ms', '550ms']
        textCreate(pygame,screen,"We will start with a pace of 350ms! Remember to continue the pace", white)
        pygame.time.delay(5000)
        clearScreen(screen)
    else:
        session =  ['1']
        trial_type = ['550ms', '350ms']
        textCreate(pygame,screen,"We will start with a pace of 550ms! Remember to continue the pace", white)
        pygame.time.delay(5000)
        clearScreen(screen)

    while trial != trials:
        for event in pygame.event.get():
            if event.type == pygame.QUIT: 
                sys.exit()
   

        #Run a trial
        textCreate(pygame, screen,"X", white)
        pygame.time.delay(1000)

        if trial < 10 and first == 0:
            playAudio(pygame, 0)
        elif trial < 10 and first == 1:
            playAudio(pygame, 1)
        elif trial >= 10 and first == 1:
            playAudio(pygame, 0)
        elif trial >= 10 and first == 0:
            playAudio(pygame, 1)
        play_time = mouseClick(pygame, 25)
        playTone(16000, 500,2)

        #Consolidate data
        for i in play_time:
            player_times.append(i)

        #Feedback calculation
        r = rate(play_time)
        rr = round_rate(play_time)

        std_now = stdev(r[2:])
        mean_now = mean(r[2:])

        std.append(std_now)
        m.append(mean_now)

        r_std_now = stdev(rr)
        r_mean_now = mean(rr)

        r_std.append(r_std_now)
        r_m.append(r_mean_now)

        #Next Trial
        clearScreen(screen)
        trial+=1
        if trial == trials:
            textCreate(pygame, screen, "Your average pace: %s, Your standard deviation: %s" %(mean_now, int(std_now)), white)
            pygame.time.delay(4000)
            textCreate(pygame, screen,"You are done! Thank you!", white)
        elif trial == 10 and first == 0:
            textCreate(pygame, screen, "Your average pace: %s, Your standard deviation: %s" %(mean_now, int(std_now)), white)
            pygame.time.delay(4000)
            textCreate(pygame, screen, "The pace will now change to 550ms", white)
            pygame.time.delay(2000)
            textCreate(pygame, screen,"Trial complete. Prepare for next trial.", white)
        elif trial == 10 and first == 1:
            textCreate(pygame, screen, "Your average pace: %s, Your standard deviation: %s" %(mean_now, int(std_now)), white)
            pygame.time.delay(4000)
            textCreate(pygame, screen, "The pace will now change to 350ms", white)
            pygame.time.delay(2000)
            textCreate(pygame, screen,"Trial complete. Prepare for next trial.", white)
        else:
            textCreate(pygame, screen, "Your average pace: %s, Your standard deviation: %s" %(mean_now, int(std_now)), white)
            pygame.time.delay(4000)
            textCreate(pygame, screen,"Trial complete. Prepare for next trial.", white)
        pygame.time.delay(3000)