示例#1
0
def intialize_screen(window, text1, text2, text3, text4, gauge1_startx,
                     gauge1_starty, gauge2_startx, gauge2_starty):

    global light1_obj, light2_obj, gauge1_obj, gauge2_obj

    light1_on(window, text1, "intial")
    light2_on(window, text2, "intial")

    gauge1_obj = actr.add_text_to_exp_window(window,
                                             text3,
                                             x=gauge1_startx,
                                             y=gauge1_starty,
                                             color="black")
    actr.add_line_to_exp_window(window, [gauge1_startx + 10, 150],
                                [gauge1_startx + 20, 150],
                                color=False)
    actr.add_line_to_exp_window(window, [gauge1_startx + 10, 250],
                                [gauge1_startx + 20, 250],
                                color=False)

    gauge2_obj = actr.add_text_to_exp_window(window,
                                             text4,
                                             x=gauge2_startx,
                                             y=gauge2_starty,
                                             color="black")
    actr.add_line_to_exp_window(window, [gauge2_startx + 10, 150],
                                [gauge2_startx + 20, 150],
                                color=False)
    actr.add_line_to_exp_window(window, [gauge2_startx + 10, 250],
                                [gauge2_startx + 20, 250],
                                color=False)
示例#2
0
def graph_it(data):

    win = actr.open_exp_window("Irregular Verbs correct",visible=True,width=500,height=475)
    low = min(data)
    zoom = min([.9,math.floor(10 * low)/10])

    actr.clear_exp_window(win)
    actr.add_text_to_exp_window(win, "1.0", x=5, y=5, width=22)
    actr.add_text_to_exp_window(win, "%0.2f" % zoom, x=5, y=400, width=22)
    actr.add_text_to_exp_window(win, "%0.2f" % (zoom + ((1.0 - zoom) / 2)), x=5, y=200, width=22)

    actr.add_text_to_exp_window(win, "Trials", x=200, y=420, width=100)
    actr.add_line_to_exp_window(win,[30,10],[30,410],'black')
    actr.add_line_to_exp_window(win,[450,410],[25,410],'black')

    for i in range(10):
        actr.add_line_to_exp_window(win,[25,10 + i*40],[35,10 + i*40],'black')

    start = data[0]
    increment = max([1.0,math.floor( 450 / len(data))])
    r = math.floor (400/ (1.0 - zoom))
    intercept = r + 10
    lastx =30
    lasty = intercept - math.floor(r * start)
    
    for p in data[1:]:
        x = lastx + 30
        y = intercept - math.floor(r * p)

        actr.add_line_to_exp_window(win,[lastx,lasty],[x,y],'red')
        lastx = x
        lasty = y
def update_current_line():
    global current_line, done

    if current_stick == target:
        done = True
        actr.modify_line_for_exp_window(current_line, [75, 330],
                                        [target + 75, 330])
        actr.add_text_to_exp_window(window, "Done", x=5, y=200)
        actr.add_text_to_exp_window(window,
                                    "对标成功!",
                                    x=300,
                                    y=200,
                                    color='red',
                                    height=20,
                                    width=75,
                                    font_size=24)
    elif current_stick == 0:
        if current_line:
            actr.remove_items_from_exp_window(window, current_line)
            current_line = None
    elif current_line:
        actr.modify_line_for_exp_window(current_line, [75, 330],
                                        [current_stick + 75, 330])
    else:
        current_line = actr.add_line_to_exp_window(window, [75, 330],
                                                   [current_stick + 75, 330],
                                                   "blue")
示例#4
0
def update_current_line():
    global current_line,done

    if current_stick == target:
        done = True
        actr.modify_line_for_exp_window(current_line, [75,135], [target + 75,135])
        actr.add_text_to_exp_window(window, "Done", x=180, y=200)
    elif current_stick == 0:
        if current_line:
            actr.remove_items_from_exp_window(window,current_line)
            current_line = None
    elif current_line:
        actr.modify_line_for_exp_window(current_line,[75,135],[current_stick + 75,135])
    else:
        current_line = actr.add_line_to_exp_window(window,[75,135],[current_stick + 75,135],"blue")
示例#5
0
def build_display(a, b, c, goal):
    global window, target, current_stick, done, current_line, choice

    target = goal
    current_stick = 0
    done = False
    choice = None
    current_line = None
    window = actr.open_exp_window("Building Sticks Task",
                                  visible=visible,
                                  width=600,
                                  height=400)

    actr.add_button_to_exp_window(window,
                                  text="A",
                                  x=5,
                                  y=23,
                                  action=["bst-button-pressed", a, "under"],
                                  height=24,
                                  width=40)
    actr.add_button_to_exp_window(window,
                                  text="B",
                                  x=5,
                                  y=48,
                                  action=["bst-button-pressed", b, "over"],
                                  height=24,
                                  width=40)
    actr.add_button_to_exp_window(window,
                                  text="C",
                                  x=5,
                                  y=73,
                                  action=["bst-button-pressed", c, "under"],
                                  height=24,
                                  width=40)
    actr.add_button_to_exp_window(window,
                                  text="Reset",
                                  x=5,
                                  y=123,
                                  action="bst-reset-button-pressed",
                                  height=24,
                                  width=65)

    actr.add_line_to_exp_window(window, [75, 35], [a + 75, 35], "black")
    actr.add_line_to_exp_window(window, [75, 60], [b + 75, 60], "black")
    actr.add_line_to_exp_window(window, [75, 85], [c + 75, 85], "black")
    actr.add_line_to_exp_window(window, [75, 110], [goal + 75, 110], "green")
示例#6
0
def draw_graph(points):

    w = actr.open_exp_window('Data', visible=True, width=550, height=460)
    actr.add_line_to_exp_window(w, [50, 0], [50, 420], 'white')

    for i in range(11):
        actr.add_text_to_exp_window(w,
                                    "%3.1f" % (1.0 - (i * .1)),
                                    x=5,
                                    y=(5 + (i * 40)),
                                    width=35)
        actr.add_line_to_exp_window(w, [45, 10 + (i * 40)],
                                    [550, 10 + (i * 40)], 'white')

    x = 50

    for (a, b) in zip(points[0:-1], points[1:]):
        actr.add_line_to_exp_window(
            w, [x, math.floor(410 - (a * 400))],
            [x + 25, math.floor(410 - (b * 400))], 'blue')
        x += 25
def build_display(a, b, c, d, e, f, goal):
    global window, target, current_stick, done, current_line, choice

    target = goal
    current_stick = 0
    done = False
    choice = None
    current_line = None
    window = actr.open_exp_window("停车对标",
                                  visible=visible,
                                  width=600,
                                  height=400)

    actr.add_button_to_exp_window(window,
                                  text="A",
                                  x=5,
                                  y=23,
                                  action=["bst-button-pressed", a, "under"],
                                  height=24,
                                  width=40)
    actr.add_button_to_exp_window(window,
                                  text="B",
                                  x=5,
                                  y=48,
                                  action=["bst-button-pressed", b, "over"],
                                  height=24,
                                  width=40)
    actr.add_button_to_exp_window(window,
                                  text="C",
                                  x=5,
                                  y=73,
                                  action=["bst-button-pressed", c, "under"],
                                  height=24,
                                  width=40)
    actr.add_button_to_exp_window(window,
                                  text="D",
                                  x=5,
                                  y=98,
                                  action=["bst-button-pressed", d, "under"],
                                  height=24,
                                  width=40)
    actr.add_button_to_exp_window(window,
                                  text="E",
                                  x=5,
                                  y=120,
                                  action=["bst-button-pressed", e, "under"],
                                  height=24,
                                  width=40)
    actr.add_button_to_exp_window(window,
                                  text="F",
                                  x=5,
                                  y=140,
                                  action=["bst-button-pressed", f, "under"],
                                  height=24,
                                  width=40)

    # actr.add_text_to_exp_window(window, text="实际距离: ", x=5, y=123, height=24, width=65)
    actr.add_button_to_exp_window(window,
                                  text="Reset",
                                  x=5,
                                  y=340,
                                  action="bst-reset-button-pressed",
                                  height=24,
                                  width=65)
    actr.add_line_to_exp_window(window, [75, 35], [a + 75, 35], "black")
    actr.add_line_to_exp_window(window, [75, 60], [b + 75, 60], "black")
    actr.add_line_to_exp_window(window, [75, 85], [c + 75, 85], "black")
    actr.add_line_to_exp_window(window, [75, 110], [d + 75, 110], "black")
    actr.add_line_to_exp_window(window, [75, 135], [e + 75, 135], "black")
    actr.add_line_to_exp_window(window, [75, 160], [f + 75, 160], "black")
    actr.add_line_to_exp_window(window, [75, 310], [goal + 75, 310], "green")
    # actr.add_line_to_exp_window(window, [75, 320], [current_stick + 75, 215], "blue")
    actr.add_text_to_exp_window(
        window,
        "注意!\nB表示目标距离;模型先注视ABCDEF四条线,之后将目标线与C对比,求其差值,依次比较A,D,E,F,直至出现Done,结束对标。\nA表示四级制动,制动距离较长;"
        "\nC表示一级制动,制动距离最长;",
        x=400,
        y=310,
        color='blue',
        height=200,
        width=150,
        font_size=12)
示例#8
0
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")
示例#9
0
def drawLine(start, end):
    global window
    actr.add_line_to_exp_window(window, start, end, 'black')