def example():

    global ids

    actr.reset()

    actr.add_command("custom-object-chunk", custom_object_chunk,
                     "Command to dynamically create visual object")

    # Here we install our custom function using an object-creator device
    actr.install_device(["vision", "object-creator", "custom-object-chunk"])

    # Now we add two features to the display, the first of which will
    # have the object created by the custom function and the other by
    # the default mechanism.

    ids = actr.add_visicon_features(["screen-x", 10, "screen-y", 20],
                                    ["screen-x", 100, "screen-y", 20])

    # run to give vision module a chance to
    # process those features and then print the
    # visicon.

    actr.run_n_events(3)
    actr.print_visicon()

    # run to have model complete task
    actr.run(1)

    actr.remove_command("custom-object-chunk")
Example #2
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
def example ():
  
    actr.reset()
  
    """
    We will create two items in the display and have the model
    find them and move the mouse to them to see the difference
    in timing based on the width function setting.

    One feature will use the normal visual-location and object
    chunk-types and the other will use a custom visual-location
    type defined like this which replaces screen-x, screen-y,
    and distance with slots named x, y, and z instead.

    (chunk-type custom-location x y z height width size)

    The feature with using the standard visual-location slots
    will include a custom width function to make it act like
    a circle with twice its given height.
    """

    actr.add_command("custom-width", custom_width, "Return twice the height of a visual feature.")
  
  
    actr.add_visicon_features(['screen-x', 50, 'screen-y', 500, 'height', 20, 'width', 20, ':width-fn', "'custom-width'"],
                              ['isa', 'custom-location', 'x', 150, 'y', 500, 'height', 20, 'width', 20, ':x-slot', 'x', ':y-slot', 'y', ':z-slot', 'z'])
  
    # Give the vision module a chance to process the display
    # before printing the visicon.
  
    actr.run_n_events(3)
    actr.print_visicon()
  
    # run the model to move the cursor to 100,0 as a starting point.
    # and from there move to the left location, back to the start, and then
    # the right location.
  
    actr.run(10)
  
    actr.remove_command('custom-width')
Example #4
0
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)
Example #6
0
def example():

    actr.reset()
    """
    Add-visicon-features returns a list of names which can be
    used to update the features which were added to the visicon.
    The modify-visicon-features command can be used to adjust
    the location and object representation of an item that was
    added to the visicon.  The delete-visicon-features and
    delete-all-visicon-features commands can be used to remove
    items which were added to the visicon.

    For this example these chunk-types are defined in the model
    which subclass the standard visual-location and visual-object
    chunk-types as were used for the new-visicon-features example.
  
    (chunk-type (polygon-feature (:include visual-location)) regular)
    (chunk-type (polygon (:include visual-object)) sides)
    """

    features = actr.add_visicon_features([
        'isa', ['polygon-feature', 'polygon'
                ], 'screen-x', 0, 'screen-y', 50, 'value',
        ('polygon', "'poly1'"), 'height', 20, 'width', 40, 'color', 'blue',
        'regular', ['false', None], 'sides', [None, 7]
    ], [
        'isa', ['polygon-feature', 'polygon'], 'screen-x', 50, 'screen-y', 70,
        'value', ['polygon', "'square'"], 'height', 30, 'width', 30, 'color',
        'red', 'regular', ['true', None], 'sides', [None, 4]
    ])

    # Give the vision module a chance to process the display
    # before printing the visicon.

    actr.run_n_events(3)
    actr.print_visicon()

    # run the model to show the current chunks
    actr.run(10)
    """
    Modify the first of those features to change the color to green,
    adjust the x position, and change the number of sides to 8.
    The parameters for modify-visicon-features are very similar to
    add except that the list of features must start with the name
    of the feature to update which was returned from add-visicon-features.
    One thing to note is that because nil is used in the list of values to
    indicate that a slot should not be applied to the location or object 
    means that you can't use nil to 'remove' a slot from a feature through
    a modification.
    """

    actr.modify_visicon_features(
        [features[0], 'color', 'green', 'screen-x', 5, 'sides', [None, 8]])

    # Give the vision module a chance to process the display
    # before printing the visicon.

    actr.run_n_events(3)
    actr.print_visicon()

    # run the model to show the update
    actr.run(10)

    # Modify the second of those features to change the regular value to false and the
    # height to 25

    actr.modify_visicon_features(
        [features[1], 'height', 25, 'regular', ['false', None]])

    # Give the vision module a chance to process the display
    # before printing the visicon.

    actr.run_n_events(3)
    actr.print_visicon()

    # run the model to show the update
    actr.run(10)

    # delete the second feature.  delete-visicon-features takes any number
    # of parameters each of which should be the name of a feature that was
    # returned by add-visicon-feature and those features are removed from
    # the visicon.

    actr.delete_visicon_features(features[1])

    # Give the vision module a chance to process the display
    # before printing the visicon.

    actr.run_n_events(3)
    actr.print_visicon()

    # run the model to show the update
    actr.run(10)

    # delete all of the visicon features.  delete-all-visicon-features
    # removes all of the features from the visicon.

    actr.delete_all_visicon_features()

    # Give the vision module a chance to process the display
    # before printing the visicon.

    actr.run_n_events(3)
    actr.print_visicon()

    # run the model to show the update
    actr.run(10)
Example #7
0
def example():
  
    actr.reset()
  
    """ 
    Add-visicon-features allows the modeler to specify arbirary
    visual features for the visicon of a model.  Any number of
    features can be provided at once, and each feature represents
    an object and its location.  The description of those items
    is provided in much the same way that one specifies a chunk
    i.e. as slot-value pairs, and internally the vision module
    uses three chunks to represent that item (the location, the
    object, and a feature which contains the information that 
    can be 'found' through a visual-location request).

    All features must have an x and y position which default
    to being in the screen-x and screen-y slots (see the
    new-location-slots example for how to change that).  The
    distance (z position) can be specified, but if not the
    default distance will be included.  Similarly, a size
    (which is measured in degrees of visual angle squared)
    can be provided, but if not it will be computed from the
    height and width if specified or set to a default size if
    those are not provided.  
  
    When specifying the slot-value pairs to describe a feature
    the slot must be a valid slot for chunks (or the name isa
    to declare a chunk-type).  The value can be provided as
    either an explict value or a list of two values.  If
    an explicit value is provided then that value represents
    the value of that slot for both the location and object
    except when it is one of the x, y, or z coordinates which
    are only provided in the location.  If a list of values
    is provided then the first one represents the value of
    that slot for the visual-location chunk and the second
    one represents the value of the slot for the object.
    Either of the items can be specified as None to indicate
    that the corresponding chunk should not have that slot.
    The value for the feature which can be found through the
    visual-location request is the value for the object if
    one is provided otherwise it will be the value for the
    location.
  
    The isa specification can also take a list of two values which
    indicate the chunk-types to specify when creating the chunks
    for the location and object, which can include default slot
    values.  In addition to that, if a chunk-type is declared for
    the object and no slot named kind is specified for the feature
    then the location chunk will include a kind slot with a value
    that matches the chunk-type declared for the object.
  
    For this example these chunk-types are defined in the model
    which subclass the standard visual-location and visual-object
    chunk-types.
  
    (chunk-type (polygon-feature (:include visual-location)) regular)
    (chunk-type (polygon (:include visual-object)) sides)
    (chunk-type (square (:include polygon)) (sides 4) (square t))

    and the oval type is predefined by the vision module like this:

    (chunk-type (oval (:include visual-object)) (oval t))

    One final thing to note is that if one wants to specify a
    string as a value for a slot it must be specified using
    a set of single quotes inside the double quotes of a
    string because when sent to ACT-R strings are interpreted as 
    names/symbols by default for the visicon features.
    """  

    actr.add_visicon_features(['screen-x', 0, 'screen-y', 5, 'regular', 'true'],
                              ['isa', ['visual-location', 'oval'], 'screen-x', 12, 'screen-y', 20, 
                               'value', ['oval', "'the oval'"], 'height', 10, 'width', 40, 
                               'color', 'blue'],
                              ['isa', ['polygon-feature', 'polygon'], 'screen-x', 50, 'screen-y', 50,
                               'value', ('polygon', "'poly 1'"), 'height', 20, 'width', 40, 
                               'color', 'blue', 'regular', ['false', None], 
                               'sides', [None, 7]],
                              ['isa', ['polygon-feature', 'square'], 'screen-x', 10, 'screen-y', 50, 
                               'value', ['square', "'the square'"], 'height', 30, 'width', 30, 
                               'color', 'red', 'regular', ['true', None], 
                               'sides', [None, 4]],
                              ['isa', ['polygon-feature', 'polygon'], 'screen-x', 5, 'screen-y', 70, 
                               'value', ['polygon', "'poly 2'"], 'height', 50, 'width', 45, 
                               'color', 'green', 'regular', ['false', None], 
                               'sides', [None, 5]])
                                     
    
    # Give the vision module a chance to process the display
    # before printing the visicon.
    
    actr.run_n_events(3)
    actr.print_visicon()
    
    # Then just run the model
    actr.run(10)