def do_experiment(sticks, human=False): build_display(*sticks) if human: wait_for_human() else: actr.install_device(window) actr.start_hand_at_mouse() actr.run(100, visible)
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
def run_test(visible=False): actr.reset() win = actr.open_exp_window("background test", visible=visible, width=390, height=390, x=100, y=100) actr.install_device(win) actr.start_hand_at_mouse() actr.add_image_to_exp_window(win, "background", "ref-brain.gif", x=0, y=0, width=390, height=390) for x in range(3): for y in range(3): actr.add_visicon_features([ "screen-x", 164 + (x * 130), "screen-y", 164 + (y * 130), "height", 128, "width", 128, "name", ["'brain'", "'brain-%d'" % (x + (y * 3))] ]) # run for the vision module to process the scene actr.run_n_events(2) actr.print_visicon() # run for up to 5 seconds using real-time if the window is visible actr.run(10, visible)
def run_test (visible=False): actr.reset() win = actr.open_exp_window("image test",visible=visible, width=310, height=420) actr.install_device(win) actr.start_hand_at_mouse() actr.add_image_to_exp_window(win, "logo", "smalllogo.gif", x=10, y=10, width=288, height=142) actr.add_items_to_exp_window(win, actr.create_image_for_exp_window(win, "brain", "ref-brain.gif", x=10, y=160, width=128, height=128, action="click-brain-py")) actr.add_image_to_exp_window(win, "brain-2", "ref-brain.gif", x=10, y=290, width=128, height=128, action=["click-brain-2-py","this string"]) # run for the vision module to process the scene actr.run_n_events(2) actr.print_visicon() # run for up to 5 seconds using real-time if the window is visible actr.run(5, visible)
def run_experiment(start_point, end_point, verbose=True, visible=True, trace=True): """Runs an experiment""" actr.reset() # current directory actr.load_act_r_model(r"C:\Users\syl\Desktop\ACTR_ATO\sp_new_2.lisp") window = actr.open_exp_window("* Speed trace *", width=800, height=600, visible=visible) actr.install_device(window) # actr.add_text_to_exp_window(window, text="当前推荐速度:", x=10, y=60, height=40, width=95, color='black', font_size=22) # actr.add_text_to_exp_window(window, text="当前速度差值:", x=10, y=20, height=40, width=180, color='black', font_size=22) # actr.add_text_to_exp_window(window, text="当前实际速度:", x=10, y=100, height=40, width=95, color='black', font_size=22) # actr.add_text_to_exp_window(window, text="距离车站位置:", x=10, y=140, height=40, width=95, color='black', font_size=22) # actr.add_text_to_exp_window(window, text="当前速度差值:", x=10, y=180, height=40, width=95, color='black', font_size=22) # actr.add_button_to_exp_window(window, text="7", x=500, y=80, action=["sp-button-pressed", 0.2, "up"], height=20, width=100, color='yellow') # actr.add_button_to_exp_window(window, text="6", x=500, y=100, action=["sp-button-pressed", 0.2, "up"],height=20, width=100, color='yellow') # actr.add_button_to_exp_window(window, text="5", x=500, y=120, action=["sp-button-pressed", 0.2, "up"], height=20, width=100, color='yellow') # actr.add_button_to_exp_window(window, text="4", x=500, y=140, action=["sp-button-pressed", 0.2, "up"], height=20, width=100, color='yellow') # actr.add_button_to_exp_window(window, text="3", x=500, y=160, action=["sp-button-pressed", 0.2, "up"], height=20, width=100, color='yellow') # actr.add_button_to_exp_window(window, text="2", x=500, y=180, action=["sp-button-pressed", 0.2, "up"], height=20, width=100, color='yellow') actr.add_button_to_exp_window(window, text="up", x=500, y=200, action=["sp-button-pressed-up-keep-down", 1, "up"], height=20, width=100,color='yellow') actr.add_button_to_exp_window(window, text="keep", x=500, y=220, action=["sp-button-pressed-up-keep-down", 0, "keep"], height=20, width=100, color='gray') actr.add_button_to_exp_window(window, text="down", x=500, y=240, action=["sp-button-pressed-up-keep-down", 1, "down"], height=20, width=100, color='green') # actr.add_button_to_exp_window(window, text="-2", x=500, y=260, action=["sp-button-pressed", 0.2, "down"], height=20, width=100, color='green') # actr.add_button_to_exp_window(window, text="-3", x=500, y=280, action=["sp-button-pressed", 0.2, "down"], height=20, width=100, color='green') # actr.add_button_to_exp_window(window, text="-4", x=500, y=300, action=["sp-button-pressed", 0.2, "down"], height=20, width=100, color='green') # actr.add_button_to_exp_window(window, text="-5", x=500, y=320, action=["sp-button-pressed", 0.2, "down"], height=20, width=100, color='green') # actr.add_button_to_exp_window(window, text="-6", x=500, y=340, action=["sp-button-pressed", 0.2, "down"], height=20, width=100, color='green') # actr.add_button_to_exp_window(window, text="-7", x=500, y=360, action=["sp-button-pressed", 0.2, "down"], height=20, width=100, color='green') actr.add_button_to_exp_window(window, text="10", x=500, y=260, action=["sp-button-pressed-up-keep-down", 1, "EB"], height=20, width=100, color='red') actr.add_command("sp-button-pressed-up-keep-down", button_pressed, "sp press button(up\keep\down) task") actr.start_hand_at_mouse() for i in range(start_point, end_point): target_speed = train_model().target_v(i) actual_speed = 10 delta_speed = actual_speed - target_speed print(delta_speed) t_group.append(i) target_group.append(target_speed) actual_group.append(actual_speed) if delta_speed > 0: delta_speed_show = "+" elif delta_speed < 0: delta_speed_show = "-" else: delta_speed_show = "0" print(i, str(int(target_speed))) deltasudu = actr.add_text_to_exp_window(window, delta_speed_show, x=200, y=30, height=40, width=95,color='red', font_size=22) # mubiaosudu = actr.add_text_to_exp_window(window, "*", x=220, y=30, height=40, width=95,color='red', font_size=22) mubiaosudu = actr.add_text_to_exp_window(window, str(round(target_speed)), x=240, y=30,height=40, width=95, color='red', font_size=22) # shijisudu = actr.add_text_to_exp_window(window, str(int(actual_speed)), x=200, y=100, height=40, width=95,color='red', font_size=22) EB = actr.add_text_to_exp_window(window, "10", x=280, y=30,height=40, width=95, color='red', font_size=22) actualline = actr.add_line_to_exp_window(window, [180, 80], [280+ round(target_speed), 80], "red") modifyline = actr.modify_line_for_exp_window(actualline, [180, 80], [280 + round(target_speed), 80], "blue") # actualline = modifyline # actr.remove_items_from_exp_window(window, modifyline) actr.run(100, True) # actr.print_visicon() # print("****************************end cmd actr.print_visicon()**********************************") # actr.all_productions() # print("****************************end cmd actr.all_productions()**********************************") # actr.clear_buffer("visual") # actr.act_r_output(actr.dm()) # actr.buffer_read("manual") # print("****************************end cmd actr.buffer_read(manual)**********************************") actr.remove_items_from_exp_window(window, deltasudu) actr.remove_items_from_exp_window(window, mubiaosudu) # actr.remove_items_from_exp_window(window, shijisudu) Game().draw_target_actual_speed(t_group, target_group, actual_group) actr.remove_command_monitor("output-key", "sp-key-press")