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

APT.all-test.MOUTBot.record-threat.soar Maven / Gradle / Ivy

echo "\nLoading record-threat"

## Create link to a new enemy
# [1] REW: 2002-07-27wr
#     Don't record a threat for an agent for any friendly team members
#     Note that MOUT under ^entity.agent.name is not upcased.  They have
#     to be |MoutBot1| to match here.
# AMN: 2002-08-02 - Added |Player| as a friendly team member so agent will
#                   ignore the "ghost" that shows up.  (Devvan's working on it...)
# [3] REW: 2002-08-26
#     Added production to copy new threats to the sentry-watch structure
# [4] REW: 2002-08-28
#     Evidently the MoutBot names are now MOUTBot so I added these to the record-threat proposal
# [5] REW: 2002-09-11
#     Made basic proposal depend on active objective other than sentry-watch
#     Must assume that sentry-watch will terminate if it's ever true that a threat is present
#     (ie, where a threat is different from a contact).
#     Basic idea is to not use record threat for contacts made during sentry-watch
#     This means that sentry-watch will not record threats.
# [6] REW: 2002-09-25
#     Completed and tested changes described in [6].
#     Note that the threat is never deleted unless we can't determine
#     it's name.  The ^threat.entity is deleted/re-added as threats change
#     from visible to not visible and back again.
# [7] REW: 2003-05-27
#     Make the determination of threat be someone not on IGNORE or REDFOR scenario list
#     IF we use ^team then we can't ignore non-combatants/just ignore the player
# [8] REW: 2003-06-04
#     Only record threat based on vision (input-link.entity) if the bot is not behind
#     (this simulates peripheral vision; sensor is ready but we need sound too)
# [9] REW: 2003-06-05
#     record-threats that are behind when also underfire (not tested)


# REW: This should fire both when the active objective is not sentry-watch and also
# when there is no active objective at all.
# REW: 2003-05-27.  Added red and bvlue prods. Collapse to one production somaday
sp {unreal*propose*record-threat*red
   (state  ^name unreal
              ^io.input-link.objects.entity 
              ^self.force |Red|
             -^threats.threat.entity.name 
              # [5]: Make proposal specific to active objectives other than sentry-watch
             -^mission.active-objective.type sentry-watch
              # [7]: Determine who's on my team or who to ignore
             -^scenario.<< REDFOR IGNORE >>.name 
                           # [8]
              ^entity )
   ( ^name 
                  # [8]
            ^egocentric-location <> behind)
  # (  ^name { <> |Player| <> |MoutBot1| <> |MoutBot2| <> |MoutBot3| <> |MoutBot4| <> |MoutBot5|
  #                   <> |MOUTBot1| <> |MOUTBot2| <> |MOUTBot3| <> |MOUTBot4| <> |MOUTBot5|           } )
-->
#   (write (crlf) | Recording threat for new enemy | )
   ( ^operator  +, = 50)
   ( ^name record-threat
        ^type new
        ^entity )}

sp {unreal*propose*record-threat*red*behind*underfire
   (state  ^name unreal
              ^io.input-link.objects.entity 
              ^self.force |Red|
             -^threats.threat.entity.name 
              # [5]: Make proposal specific to active objectives other than sentry-watch
             -^mission.active-objective.type sentry-watch
              # [7]: Determine who's on my team or who to ignore
             -^scenario.<< REDFOR IGNORE >>.name 
                           # 2003-06-04
              ^entity 
              ^self.underfire.value <> none)
   ( ^name 
                  #2003-06-04
            ^egocentric-location behind)
-->
#   (write (crlf) | Recording threat for new enemy | )
   ( ^operator  +, = 50)
   ( ^name record-threat
        ^type new
        ^entity )}

sp {unreal*propose*record-threat*blue
   (state  ^name unreal
              ^io.input-link.objects.entity 
              ^self.force |Blue|
             -^threats.threat.entity.name 
              # [5]: Make proposal specific to active objectives other than sentry-watch
             -^mission.active-objective.type sentry-watch
              # [7]: Determine who's on my team or who to ignore
             -^scenario.<< BLUEFOR IGNORE >>.name )
   ( ^name )
  # (  ^name { <> |Player| <> |MoutBot1| <> |MoutBot2| <> |MoutBot3| <> |MoutBot4| <> |MoutBot5|
  #                   <> |MOUTBot1| <> |MOUTBot2| <> |MOUTBot3| <> |MOUTBot4| <> |MOUTBot5|           } )
-->
#   (write (crlf) | Recording threat for new enemy | )
   ( ^operator  +, = 50)
   ( ^name record-threat
        ^type new
        ^entity )}

## If have saved a threat and the enemy reappears on vision - replace the
## saved version with the new enemey

sp {unreal*propose*enemy-record*replace
   (state  ^name unreal
              ^io.input-link.objects.entity 
              ^threats.threat.entity { <>   })
   ( ^name 
                ^visible false)
   ( ^name 
            ^visible true
            # [8]
            ^egocentric-location <> behind)
-->
#   (write (crlf) | Recording threat for no longer visible enemy that is now visible | )
   ( ^operator  +, = 50)
   ( ^name record-threat
        ^entity 
        ^old-enemy 
        ^type replace)}


## If the enemy disappears off vision, then create a record of him

sp {unreal*propose*enemy-record*save
   (state  ^name unreal
              ^io.input-link.objects.entity 
              ^threats.threat )
   ( ^entity )
   (  ^name 
             ^visible false)
-->
#   (write (crlf) | Recording threat for no longer visible enemy | )
   ( ^operator  +, = 50)
   ( ^name record-threat
        ^entity 
        ^type save)}
                     
###### ELABORATIONS ######
       
# The production below does not work for agents that are outside.
# If there's not an area that's consistent with the threat's (x,y,z), assume it is outside

sp {unreal*record-threat*area*Outside
   (state  ^name unreal
              ^operator 
              ^top-state.map )
   ( ^name record-threat
        ^entity )
   ( ^position )
   (
            ^area )
  -{ ( ^area )
     ( ^min-x <= 
             ^min-y <= 
             ^max-x >= 
             ^max-y >= 
             ^min-z <= 
             ^max-z >= ) }
   ( ^x 
          ^y 
          ^z  )
   ( ^name |Outside|)
-->
  # (write (crlf) |Recording area Outside: |  | for this threat.|)
   ( ^area-id )
}

#Elaborate the enemy with the area that it currently resides in.
sp {unreal*record-threat*area
   (state  ^name unreal
              ^operator 
              ^top-state.map )
   ( ^name record-threat
        ^entity )
   ( ^position )
   ( ^area )
   ( ^min-x 
           ^min-y 
           ^max-x 
           ^max-y 
           ^min-z 
           ^max-z )
   ( ^x < 
          ^x > 
          ^y < 
          ^y > 
          ^z > 
          ^z < )
-->
 #  (write (crlf) |Recording area: |  | for this threat.|)
   ( ^area-id )
}


###### APPLICATIONS #####

#### NEW

sp {apply*record-threat*new
   (state  ^operator 
              ^threats )
   ( ^name record-threat
         ^type new
         ^entity 
         ^area-id )
-->
   ( ^threat  )
   ( ^entity 
         ^area-id )
}


# REW: 2002-10-08
# Record that contact has been made with the enemy
sp {apply*record-threat*new*contact-with-enemy
   (state  ^operator 
              ^threats )
   ( ^name record-threat
         ^type new)
   ( -^contact-with-enemy)
-->
   ( ^contact-with-enemy true)
}


# REW: 2002-08-26
# If there is a sentry-watch going on and we record a threat, then also record that it has not been
# reported (not all threats will be reported but we generally want to report threats observed while
# on sentry-watch)
# REW: 2002-09-26 (deleted: apply*record-threat*sentry-watch*new-threat)

## Mark all areas that the enemy is seen in.

sp {apply*record-threat*area
   (state  ^operator 
              ^threats )
   ( ^name record-threat
        ^area-id )
   ( -^controlled-area )
-->
  # (write (crlf) |Adding controlled-area |   | to the threats structure.|)
   ( ^controlled-area )
}

#### SAVE

## REW: Not sure what this is supposed to do:
## Just delete a threat that doesn't have a name?
sp {unreal*apply*record-threat*clean-up
   (state  ^operator 
              ^threats )
   ( ^name record-threat)
   ( ^threat )
   ( -^entity.name)
-->
#   (write (crlf) |Deleting threat |   | because it lacks enemy name|)
   ( ^threat  -)}

# REW: 2002-09-30
# Must not remove the old threat until the new one is created, so test for this situation.
sp {unreal*apply*record-threat*save*remove-old-enemy
   (state  ^operator 
              ^io.input-link.objects.entity 
              ^threats )
   ( ^name record-threat
        ^type save
        ^entity )
   ( ^threat )
   ( ^entity 
         ^entity {<>   })
-->
   ( ^entity  -)}

# REW: 2002-09-30
# If threats.area-id different than one on the current operator, replace old value
sp {unreal*apply*record-threat*save*remove-old-area-id
   (state  ^operator 
              ^threats )
   ( ^name record-threat
        ^type << save replace >>
        ^area-id )
   ( ^threat )
   ( ^area-id {<>  })
-->
 #  (write (crlf) |Creating new area-id for this threat: |  )
   ( ^area-id  +  -)}


# REW: 2002-09-30
# REmoved area-name addition.  This is now elaborated from the area-id (elaborations/threats.soar)
# Must make sure that the area-id on the threat is the same as the area-id on the operator before this fires.
sp {unreal*apply*record-threat*save
   (state  ^operator 
              ^io.input-link.agent.cycle 
              ^parameters.enemy-remember-time 
              ^threats )
   ( ^threat )
   ( ^entity 
         ^area-id )
   ( ^name record-threat
        ^type save
        ^entity 
        ^area-id )
   ( ^range 
            ^aspect 
            ^angle-off 
            ^health 
            ^weapon 
            ^position 

^team ^name ) ( ^name ) ( ^v ^h ) (

^x ^y ^z ) ( ^v ^h ) --> # (write (crlf) |Saving information about disappearing threat: | ) ( ^entity ^last-seen-time ) ( ^name ^area ^team ^position ^health ^weapon ^range ^aspect ^angle-off ^visible false ) ( ^h ^v ) ( ^x ^y ^z ) ( ^v ^h ) } #### REPLACE # REW: 2002-09-30 # Don't replace the old-enemy and the new onw unless the area-id on the threat is the same as on the operator. sp {unreal*apply*record-threat*replace (state ^operator ^threats ) ( ^name record-threat ^type replace ^entity ^old-enemy ^area-id ) ( ^threat ) ( ^entity ^area-id ) --> ( ^entity - +)} # REW: 2002-09-25 # When replacing a threat, delete the last-seen-time, area-id, and area-name sp {unreal*apply*record-threat*replace*delete*last-seen-time (state ^operator ^threats ) ( ^name record-threat ^type replace ^entity ^old-enemy ) ( ^threat ) ( ^entity ^last-seen-time ) --> ( ^last-seen-time -)} sp {unreal*apply*record-threat*replace*delete*not-visible (state ^operator ^threats ) ( ^name record-threat ^type replace ^old-enemy ) ( ^threat ) ( ^entity ^not-visible ) --> ( ^not-visible -)} # REW: 2002-08-26 # When a threat appears that we have previously seen, record it on the # sentry-watch structure iff it hasn't been reported before for this # sentry-watch objective. # REW: 2002-09-26 (delete: apply*record-threat*sentry-watch*new-threat*replace) ### SEARCH CONTROL sp {unreal*select*record-threat (state ^name unreal ^operator + ^operator +) ( ^name record-threat) ( ^name << execute-mission explore >>) --> ( ^operator > )}