All Downloads are FREE. Search and download functionalities are using the official Maven repository.

APT.all-test.HauntBot.elaborations.navigation.soar Maven / Gradle / Ivy

echo "\nLoading elaborations/navigation"

# set up the map on the top level

sp {navigation*elaborate*map
   (state  ^superstate nil)
-->
   ( ^map )
   ( ^area-names )
   ( ^name |Outside|)
}

sp {elaborate*direction-headings
   (state  ^name haunt)
-->
   ( ^direction-headings )
   ( ^north 90
         ^south 270
         ^east 0
         ^west 180)}

#record that we are near a node; will
#disappear as soon as agent moves away
sp {navigation*elaborate*map-near-node
   (state  ^name haunt
              ^map 
              ^io.input-link 
              ^parameters.near-node-range )
   ( ^objects.node )
   ( -^range > 
               ^name 
               ^area-name )
   ( ^area )
   ( ^name 
           ^node )
   ( ^name )
-->
   ( ^near-node )
#   (write (crlf) |I am NEAR node | )
}

## JEL - must support both area and area-name to access area for now.
sp {navigation*elaborate*map-near-node2
   (state  ^name haunt
              ^map 
              ^io.input-link 
              ^parameters.near-node-range )
   ( ^objects.node )
   ( -^range > 
               ^name 
               ^area )
   ( ^area )
   ( ^name 
           ^node )
   ( ^name )
-->
   ( ^near-node )
#   (write (crlf) |I am NEAR node | )
}

## JEL: 2002-08-13
# Had to change so would have i-support - means lots of calculations.
#AMN: 2002-08-02
#If the agent is moving to a _derived_ corner node
#(rather than one actually seen on the input-link)
#then these rule will identify when the agent is near it
#and elaborate the map accordingly.
sp {navigation*elaborate*derived-node*range
   (state  ^name haunt
              ^map.current-area.node 
              ^io.input-link.agent.position )
   ( ^derived yes
           ^position )
   ( ^x 
          ^y )
   ( ^x 
           ^y )
-->
   ( ^range (compute-range    ))
}

sp {navigation*elaborate*map-near-node*derived
   (state  ^name haunt
              ^map 
              ^parameters.near-xy-range )
   ( ^current-area.node )
   ( ^derived yes
          -^range > )
-->
   ( ^near-node )
}

#record the current nearest visible node in my area
sp {navigation*elaborate*nearest-node
   (state  ^name haunt
              ^map 
              ^io.input-link.objects )
   ( ^current-area )
   ( ^name 
           ^node )
   ( ^name )
   ( ^node )
   ( ^name 
              ^area-name 
              ^range )
  -{
   ( ^node )
   ( ^name { <>  }
                   ^area-name 
                  -^range >= )
}
-->
   ( ^nearest-node )
}
   
sp {navigation*elaborate*map-nearest-node*derived
   (state  ^map )
   ( ^current-area.node 
         -^current-area.node.range <  )
   ( ^node )
   ( ^derived yes
            ^range  )
-->
   ( ^nearest-node )
}
#Record what nodes are in front of me
sp {navigation*elaborate*nodes-in-front
   (state  ^name haunt
              ^map 
              ^io.input-link.objects.node 
              ^parameters 

) (

^right-angle-threshold ^left-angle-threshold ) ( -^angle-off.h { > < } ^name ) ( ^area ) ( # ^name # Doesn't work for outside nodes ^node ) ( ^name ) --> ( ^in-front-node ) # (write (crlf) |I see | | in front of me.|) } sp {navigation*elaborate*nodes-in-front2 (state ^name haunt ^map ^io.input-link.objects.node ^parameters

) (

^right-angle-threshold ^left-angle-threshold ) ( -^angle-off.h { > < } ^name ^area ) ( ^area ) ( ^name ^node ) ( ^name ) --> ( ^in-front-node ) # (write (crlf) |I see | | in front of me.|) } #If I'm at a boundary between areas, it's useful to know what areas are nearby sp {haunt*elaborate*near-area (state ^name haunt ^top-state.map ) ( ^current-area ^near-node.area { <> }) --> ( ^near-area ) } ## Maintain current-area and previous area. ## ## JEL 8/8/2002 ## Reimplemented way we keep track of current area because ## it no longer comes in from the input link but must be computed from ## x, y location. sp {haunt*initialize*current-area*previous-area :o-support (state ^name haunt ^top-state.map ^io.input-link.agent.position

) ( ^area -^current-area) ( ^name ^min-x ^min-y ^max-x ^max-y ^min-z ^max-z ) (

-^x > -^x < -^y > -^y < -^z < -^z > ) --> ( ^current-area ^previous-area none) } # MJP 5/21/03: Updated to increment area's 'visit-count' each time a new area is entered sp {haunt*elaborate*current-area :o-support (state ^name haunt ^top-state.map ^io.input-link.agent ) ( ^position

^time

^x <= ^x >= ^y <= ^y > ^z > ^z <= ) # ## The following conditions are here because some areas overlap and we get switching # ( ^min-x # ^min-y # ^max-x # ^max-y # ^min-z # ^max-z ) # - (

^x <= # ^x >= # ^y <= # ^y > # ^z > # ^z <= ) --> ( ^current-area - ^previous-area - ) # (write (crlf) |Updating visit time|) ( ^visit-time - #added by MJP 5/21/03 ^visit-time