コード例 #1
0
def wait_for_human():
    while not (done):
        actr.process_events()

    start = actr.get_time(False)
    while (actr.get_time(False) - start) < 1000:
        actr.process_events()
コード例 #2
0
def respond_to_key_press(model, key):
    global response, light1Color, light2Color, window, text1,text2,light1_obj, \
        light2_obj,gauge1_obj,gauge2_obj,temp1_y, responses,times

    response = key

    # specific responses for different key presses
    if (key == "a") and (light1Color == "black"):
        light1_on(window, text1, "exp")
        responses.append("a")
        times.append(actr.get_time() / 1000)

    if (key == "b") and (light2Color == "red"):
        light2_on(window, text2, "exp")
        responses.append("b")
        times.append(actr.get_time() / 1000)

    # eventually, these keys should modify the position of the gauges
    if (key == "c"):
        #temp1_y = 200
        #actr.remove_items_from_exp_window(window,gauge1_obj)
        #gauge1_obj = actr.add_text_to_exp_window(window, "C", x=60, y=200,color="black")
        responses.append("c")
        times.append(actr.get_time() / 1000)

    if (key == "d"):
        #temp2_y = 200
        #actr.remove_items_from_exp_window(window,gauge2_obj)
        #gauge2_obj = actr.add_text_to_exp_window(window, "D", x=110, y=200,color="black")
        responses.append("d")
        times.append(actr.get_time() / 1000)
コード例 #3
0
def show_human_results(own_cards, others_cards, own_result, others_result):

    win = actr.open_exp_window('Human')
    actr.add_text_to_exp_window(win, 'You', x=50, y=20)
    actr.add_text_to_exp_window(win, 'Model', x=200, y=20)

    for i in range(2):
        for j in range(3):
            actr.add_text_to_exp_window(win,
                                        "C%d" % (j + 1),
                                        x=(25 + (j * 30) + (i * 150)),
                                        y=40,
                                        width=20)
            if i == 0:
                if j < len(own_cards):
                    actr.add_text_to_exp_window(win,
                                                str(own_cards[j]),
                                                x=(25 + (j * 30) + (i * 150)),
                                                y=60,
                                                width=20)
            else:
                if j < len(others_cards):
                    actr.add_text_to_exp_window(win,
                                                str(others_cards[j]),
                                                x=(25 + (j * 30) + (i * 150)),
                                                y=60,
                                                width=20)

    actr.add_text_to_exp_window(win, own_result, x=50, y=85)
    actr.add_text_to_exp_window(win, others_result, x=200, y=85)

    start_time = actr.get_time(False)

    while (actr.get_time(False) - start_time) < 10000:
        actr.process_events()
コード例 #4
0
ファイル: choice.py プロジェクト: segsev/M.tech-2nd-sem
def person():
    global response

    window = actr.open_exp_window("Choice Experiment", visible=True)

    actr.add_command("choice-response", respond_to_key_press,
                     "Choice task key response")
    actr.monitor_command("output-key", "choice-response")

    actr.add_text_to_exp_window(window, 'choose', x=50, y=100)

    response = ''

    while response == '':
        actr.process_events()

    actr.clear_exp_window(window)

    if actr.random(1.0) < .9:
        answer = 'heads'
    else:
        answer = 'tails'

    actr.add_text_to_exp_window(window, answer, x=50, y=100)

    start = actr.get_time(False)

    while (actr.get_time(False) - start) < 1000:
        actr.process_events()

    actr.remove_command_monitor("output-key", "choice-response")
    actr.remove_command("choice-response")

    return response
コード例 #5
0
ファイル: paired.py プロジェクト: segsev/M.tech-2nd-sem
def do_experiment(size, trials, human):

    actr.reset()

    result = []
    model = not (human)
    window = actr.open_exp_window("Paired-Associate Experiment", visible=human)

    if model:
        actr.install_device(window)

    for i in range(trials):
        score = 0
        time = 0

        for prompt, associate in actr.permute_list(pairs[20 - size:]):

            actr.clear_exp_window(window)
            actr.add_text_to_exp_window(window, prompt, x=150, y=150)

            global response
            response = ''
            start = actr.get_time(model)

            if model:
                actr.run_full_time(5)
            else:
                while (actr.get_time(False) - start) < 5000:
                    actr.process_events()

            if response == associate:
                score += 1
                time += response_time - start

            actr.clear_exp_window(window)
            actr.add_text_to_exp_window(window, associate, x=150, y=150)
            start = actr.get_time(model)

            if model:
                actr.run_full_time(5)
            else:
                while (actr.get_time(False) - start) < 5000:
                    actr.process_events()

        if score > 0:
            average_time = time / score / 1000.0
        else:
            average_time = 0

        result.append((score / size, average_time))

    return result
コード例 #6
0
ファイル: pcomp_issues.py プロジェクト: segsev/M.tech-2nd-sem
def present_next_trial():
    global task_state,start_time,val1,val2

    task_state = 'trial'
    actr.clear_exp_window(window)
    val1 = actr.random(4)
    val2 = actr.random(4)
    actr.add_text_to_exp_window(window, str(val1), x=10, y=50)
    actr.add_text_to_exp_window(window, str(val2), x=110, y=50)
    start_time = actr.get_time()
コード例 #7
0
def present_trial(trial, new_window=True):
    if new_window:
        w = actr.open_exp_window("Alpha-arithmetic Experiment",
                                 visible=trial.visible)
        if run_model:
            actr.install_device(w)
    else:
        actr.clear_exp_window()

    actr.add_text_to_exp_window(None, trial.text, x=100, y=150)

    trial.start = actr.get_time(run_model)
コード例 #8
0
def play_human(cards, oc1):

    win = actr.open_exp_window('Human')
    actr.add_text_to_exp_window(win, 'You', x=50, y=20)
    actr.add_text_to_exp_window(win, 'Model', x=200, y=20)

    for i in range(2):
        for j in range(3):
            actr.add_text_to_exp_window(win,
                                        "C%d" % (j + 1),
                                        x=(25 + (j * 30) + (i * 150)),
                                        y=40,
                                        width=20)
            if i == 0 and j < 2:
                actr.add_text_to_exp_window(win,
                                            str(cards[j]),
                                            x=(25 + (j * 30) + (i * 150)),
                                            y=60,
                                            width=20)
            if i == 1 and j == 0:
                actr.add_text_to_exp_window(win,
                                            str(oc1),
                                            x=(25 + (j * 30) + (i * 150)),
                                            y=60,
                                            width=20)

    global human_action
    human_action = None

    start_time = actr.get_time(False)

    while (actr.get_time(False) - start_time) < 10000:
        actr.process_events()

    if human_action:
        return human_action
    else:
        return 's'
コード例 #9
0
ファイル: zbrodoff.py プロジェクト: segsev/M.tech-2nd-sem
def respond_to_key_press(model, key):
    global trials, results

    trials[0].time = (actr.get_time(run_model) - trials[0].start) / 1000.0

    if key.lower() == trials[0].answer:
        trials[0].correct = True

    results.append(trials[0])

    trials = trials[1:]

    if len(trials) > 0:
        present_trial(trials[0], False)
コード例 #10
0
def respond_to_key_press(model, key, test=False):
    """
    This function is set to monitor the output-key command, will be called whenever
    a key is pressed in the experiment window
    :param model: name of the model. if None, indicates a person interacting with
                the window
    :param key: string name of the key
    :return:
    """
    global response, response_time

    # record the latency of key-press (real time, not ACT-R time)
    response_time = actr.get_time(model)
    response = key
    if test: print("TEST: in respond_to_key_press: ", response, response_time)
コード例 #11
0
ファイル: pcomp_issues.py プロジェクト: segsev/M.tech-2nd-sem
def respond_to_key_press (model,key):
    global responses,task_over,times

    if not(task_over):
        if task_state == 'trial':
            ri = convert_key_to_index(key)
            r = result_matrix[val1][val2][ri]
            responses.append(r)
            times.append(actr.get_time() - start_time)
            present_feedback(r)
        elif key.lower() == 'space':
            if len(responses) == exp_length:
                task_over = True
            else:
                present_next_trial()
コード例 #12
0
def experiment(human=False):
    global response
    response = False
    if human == True:
        while response == False:
            actr.process_events()
    else:
        actr.install_device(window)
        actr.start_hand_at_mouse()
        actr.run(10, True)
    actr.remove_command_monitor("output-key", "sp-key-press")
    actr.remove_command("sp-key-press")
    print(actr.get_time(model_time=True))
    actr.run_n_events(2, real_time=False)
    return response
コード例 #13
0
def do_guess(prompt, window):
    """
    this function allows model to do first half of the experiment, guessing
    :param prompt:"?"
    :param window:
    :return: response "f" for less, or "j" for more
    """

    # display prompt
    actr.clear_exp_window(window)
    actr.add_text_to_exp_window(window, prompt, x=150, y=150)

    # wait for response
    global response
    response = ''

    start = actr.get_time()
    actr.run_full_time(5)
    time = response_time - start

    return response, time
コード例 #14
0
ファイル: paired.py プロジェクト: segsev/M.tech-2nd-sem
def respond_to_key_press(model, key):
    global response, response_time

    response_time = actr.get_time(model)

    response = key
コード例 #15
0
def respond_to_key_press(model, key):
    global response, response_time

    if not (response_time):
        response_time = actr.get_time()
    response.append(key.upper())