Search code examples
lispcommon-lisp

ACT-r: assigning a chunk as buffer slot value in a production rule


No sure if there's a lot of act-r programmer on here, but I can't seem to find a forum/group for that anywhere so...

I'm writing a program which as a chunk defined as (and the goal below):

(chunk-type position position-x position-y)

(chunk-type goal state last-pos)

In a production, I'm fetching the position of a thing on screen from the visual-location and then I would need to create a position chunk and put that in my goal's last-pos slot. Here's the production rule:

(P attend-projectile
   =goal>
      ISA         goal
      state       nil
   =visual-location>
        screen-x                =pos-x
        screen-y                =pos-y
   ?visual>
      state       free
==>
   +visual>
      cmd         move-attention
      screen-pos  =visual-location
   =goal>
      state       attended
      last-pos    (position pos-x screen-x pos-y screen-y)
)

Or something like that. I've tried various syntaxe. The problem boils down to:

  • I need to instantiate a chunk within a production (the position chunk) based on values recovered in the lhs,
  • then assign that chunk to a goal's slot.

Somehow I can't seem to find an equivalent example in the doc...

EDIT:

I do need this to be a chunk, not just storing the x & y position. Eventually this chunk will be extended to include an ID (which will be obtained from the visual location, e.g. a different letter will be assigned to each moving object). I will be tracking those object through time. Because I'm tracking through time, another chunk (trajectory) will contain 3 position chunks (with their IDs).

Other productions will expect to find this chunk (trajectory, once I have 3 position chunks) and make decisions based on that.

Obviously the above is a snippet of the code. But the conceptual difficulty I have is manipulating (instantiating/creating however it's called in actr nomentalture) chunks at runtime, essentially.


Solution

  • Why do you need another chunk? You have the chunk in the visual-location buffer with that information so why not use it:

    (P attend-projectile
       =goal>
          ISA         goal
          state       nil
       =visual-location>
       ?visual>
          state       free
    ==>
       +visual>
          cmd         move-attention
          screen-pos  =visual-location
       =goal>
          state       attended
          last-pos    =visual-location
    )  
    

    Of course, that doesn't answer the question that was asked.

    To create a new chunk, the proper way to do so is through a request to the imaginal buffer which would then require a following production to harvest the result and place it into the slot of the goal buffer's chunk. Assuming that the slots you want in the new chunk are from the position chunk-type you show, and that the values are from the similarly named slots of the chunk in the visual-location buffer, this would create the new chunk in the imaginal buffer:

    (P attend-projectile
       =goal>
          ISA         goal
          state       nil
       =visual-location>
          screen-x =pos-x
          screen-y =pos-y
       ?visual>
          state       free
    ==>
       +visual>
          cmd         move-attention
          screen-pos  =visual-location
       =goal>
          state       attended
       +imaginal>
          position-x =pos-x
          position-y =pos-y
    )