Ejemplo n.º 1
0
def create_set(block, visible):
    x = list(
        map(lambda x: trial(block, *x, visible=visible),
            actr.permute_list(data_set)))
    print(actr.permute_list(data_set))
    return list(
        map(lambda x: trial(block, *x, visible=visible),
            actr.permute_list(data_set)))
Ejemplo n.º 2
0
def experiment(human=False):

    actr.reset()

    items = actr.permute_list([
        "B", "C", "D", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R",
        "S", "T", "V", "W", "X", "Y", "Z"
    ])
    text1 = items[0]
    window = actr.open_exp_window("Letter recognition")

    actr.add_text_to_exp_window(window, text1, x=125, y=150)

    actr.add_command("demo2-key-press", respond_to_key_press,
                     "Demo2 task output-key monitor")
    actr.monitor_command("output-key", "demo2-key-press")

    global response
    response = False

    if human == True:
        while response == False:
            actr.process_events()

    else:
        actr.install_device(window)
        actr.run(10, True)

    actr.remove_command_monitor("output-key", "demo2-key-press")
    actr.remove_command("demo2-key-press")

    return response
Ejemplo n.º 3
0
def collect_data(n = 5000, given_train_epochs = 5, given_delay_time = 20):

    correctCount = 0
    delta = 0

    correctness_list = []

    for i in range(n):
        letter = actr.permute_list(list(string.ascii_uppercase))[0]

        (clickList, correct) = present_trial(letter,
            train_epochs = given_train_epochs, delay_time = given_delay_time);

        correctCount += correct
        delta += correct

        if (i % (n / 20) == 0):
            correctness_list.append(delta/(n/20))
            delta = 0

    print(n, given_train_epochs, given_delay_time)

    print(correctness_list)

    print (correctCount / n)
Ejemplo n.º 4
0
def one_block():

    result = []

    for t in actr.permute_list([0.0, .15, .3, 1.0]):
        result.append((t, trial(t)))

    result.sort()
    return (list(map(lambda x: x[1], result)))
Ejemplo n.º 5
0
def task(which=False):
    global response, response_time

    actr.reset()
    alphabet = [
        "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N",
        "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
    ]
    letter = actr.permute_list(alphabet)[0]
    alphabet = ["Z"] + alphabet

    if which == 'next' or which == 'previous':
        task = which
    elif actr.random(2) == 0:
        task = 'next'
    else:
        task = 'previous'

    time = 1500 + actr.random(1000)

    window = actr.open_exp_window("Simple task")

    actr.install_device(window)

    actr.add_command("pm-issues-response", respond_to_key_press,
                     "Perceptual-motor issues task response")
    actr.monitor_command("output-key", "pm-issues-response")

    actr.add_text_to_exp_window(window, letter, x=130, y=150)

    actr.add_command("pm-issue-display", display_prompt,
                     "Perceptual-motor issues task prompt display")

    actr.schedule_event_relative(time,
                                 "pm-issue-display",
                                 params=[window, task],
                                 time_in_ms=True)

    response = []
    response_time = False

    actr.run(10, True)

    actr.remove_command("pm-issue-display")
    actr.remove_command_monitor("output-key", "pm-issues-response")
    actr.remove_command("pm-issues-response")

    if (len(response) == 2 and response_time > time and response[0] == letter
            and ((task == 'next' and alphabet.index(response[0]) ==
                  (alphabet.index(response[1]) - 1)) or
                 (task == 'previous' and alphabet.index(response[0]) ==
                  (alphabet.index(response[1]) + 1)))):
        result = True
    else:
        result = False

    return [task, result]
Ejemplo n.º 6
0
def trial(onset_time):

    actr.reset()

    letters = actr.permute_list([
        "B", "C", "D", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R",
        "S", "T", "V", "W", "X", "Y", "Z"
    ])
    answers = []
    row = actr.random(3)
    window = actr.open_exp_window("Sperling Experiment", visible=True)

    for i in range(3):
        for j in range(4):
            txt = letters[j + (i * 4)]
            if i == row:
                answers.append(txt)
            actr.add_text_to_exp_window(window,
                                        txt,
                                        x=(75 + (j * 50)),
                                        y=(100 + (i * 50)))

    actr.install_device(window)

    if row == 0:
        freq = 2000
    elif row == 1:
        freq = 1000
    else:
        freq = 500

    actr.new_tone_sound(freq, .5, onset_time)
    actr.schedule_event_relative(900 + actr.random(200),
                                 "clear-exp-window",
                                 params=[window],
                                 time_in_ms=True)

    global responses
    responses = []

    actr.add_command("sperling-response", respond_to_key_press,
                     "Sperling task key press response monitor")
    actr.monitor_command("output-key", "sperling-response")

    actr.run(30, True)

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

    if show_responses:
        print("answers: %s" % answers)
        print("responses: %s" % responses)

    return (compute_score(answers))
Ejemplo n.º 7
0
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
Ejemplo n.º 8
0
def experiment(human=False):

    actr.reset()

    items = actr.permute_list([
        "B", "C", "D", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R",
        "S", "T", "V", "W", "X", "Y", "Z"
    ])
    target = items[0]
    foil = items[1]
    window = actr.open_exp_window("Letter difference")
    text1 = foil
    text2 = foil
    text3 = foil
    index = actr.random(3)

    if index == 0:
        text1 = target
    elif index == 1:
        text2 = target
    else:
        text3 = target

    actr.add_text_to_exp_window(window, text1, x=125, y=75)
    actr.add_text_to_exp_window(window, text2, x=75, y=175)
    actr.add_text_to_exp_window(window, text3, x=175, y=175)

    actr.add_command("unit2-key-press", respond_to_key_press,
                     "Assignment 2 task output-key monitor")
    actr.monitor_command("output-key", "unit2-key-press")

    global response
    response = ''

    if human == True:
        while response == '':
            actr.process_events()

    else:
        actr.install_device(window)
        actr.run(10, True)

    actr.remove_command_monitor("output-key", "unit2-key-press")
    actr.remove_command("unit2-key-press")

    if response.lower() == target.lower():
        return True
    else:
        return False
Ejemplo n.º 9
0
def present_trial(given_letter = None, train_epochs = 1,
            new_window = True, open_window = True, delay_time = 10, display = False):

    global window, window_reading, clickList, chunk_names, chunk_defs

    if (given_letter == None):
        letterList = actr.permute_list(list(string.ascii_uppercase))
        chosen_letter = letterList[0]
    else:
        chosen_letter = given_letter

    if display:
        train_n(10, chosen_letter)

    clickList = []

    actr.clear_exp_window(window_reading)
    actr.clear_exp_window(window)

    actr.add_text_to_exp_window(window_reading, chosen_letter, 125, 150)

    actr.add_command('process-click',process_click)
    actr.monitor_command('click-mouse','process-click')

    actr.run(1000, open_window)        # for actr time or real time

    correct = correct_drawing(chosen_letter, clickList)

    if (correct):
        train_once(chosen_letter)
        actr.run_full_time(delay_time)

    else:
        train_n(train_epochs, chosen_letter)
        actr.run_full_time(delay_time)

    actr.remove_command_monitor('click-mouse', 'process-click')
    actr.remove_command('process-click')

    return (clickList, correct)
Ejemplo n.º 10
0
def trial(*features):

    actr.reset()
 
    for slot,value in actr.permute_list(list(zip(slots,features))):
        attribute(slot,value)

    goal = actr.define_chunks(["state","categorize"])[0]
    actr.goal_focus(goal)
    actr.run(20)
    
    answer = actr.chunk_slot_value(actr.buffer_read("imaginal"),"category")

    if isinstance(answer,numbers.Number):
        if answer == 1 or answer == 2:
            return((answer,True))
        else:
            actr.model_output("Model responded with invalid category.")
            return((0,False))
    else:
        actr.model_output("Model did not respond or provided a non-numeric category.")
        return((0,False))