Class ActionDatabase

java.lang.Object
edu.tufts.hrilab.action.db.ActionDatabase

public class ActionDatabase extends Object
  • Constructor Details

    • ActionDatabase

      protected ActionDatabase()
      Protected so that only the Database can instantiate.
  • Method Details

    • putAction

      protected final void putAction(ActionDBEntry entry)
      Insert the action into the database. The action is keyed by its type. This function is internally synchronized on the singleton.
      Parameters:
      entry - the database entry defining this action
    • actionExists

      public final boolean actionExists(String type)
      Lookup action by type. Returns if a matching action exists.
      Parameters:
      type - the type of the action to look up
      Returns:
      if a matching action exists
    • getAction

      public final ActionDBEntry getAction(String type)
      Lookup action by type. Returns last added entry if more than one action with type.
      Parameters:
      type - the type of the action to look up
      Returns:
      the requested action (last added), if found, null otherwise
    • getAction

      public final ActionDBEntry getAction(String type, List<Class<?>> roles)
      Lookup action by type and roles.
      Parameters:
      type - the type of the action to look up
      roles - the roles of the action to look up
      Returns:
      the requested action, if found, null otherwise
    • getAction

      public final ActionDBEntry getAction(String type, Symbol actor, List<Class<?>> inputRoleTypes)
      Lookup action by type, roles and agent name
      Parameters:
      type - the type of the action to look up
      actor - the actor affected by the action to look up
      inputRoleTypes - the java types of the input roles of the action to look up
      Returns:
      the requested action, if found, null otherwise
    • removeAction

      public final void removeAction(ActionDBEntry entry)
      Remove an action from the database
      Parameters:
      entry - to remove
    • disableAction

      public final void disableAction(ActionDBEntry entry)
      Move an action into a disabledActions list so it isn't used during goal execution.
      Parameters:
      entry - to disable
    • getDisabledAction

      public final ActionDBEntry getDisabledAction(String type)
      Lookup disabled action by type. Returns last added entry if more than one action exists. Returns null if no matching action exists.
      Parameters:
      type - the type of the action to look up
      Returns:
      the requested action (last added), if found, null otherwise
    • actionExists

      public Boolean actionExists(Predicate goal)
      Check if a certain action is available in this goal manager for a particular actor
      Parameters:
      goal - goal(actor,state) or action(actor,args)
      Returns:
      true if action is in database
    • getActionsByEffect

      public List<ActionDBEntry> getActionsByEffect(Symbol actor, Predicate effect)
      Lookup by postcondition.
      Parameters:
      actor - to specify the actor that must be able to execute the action(s). Can be null.
      effect - the postcondition of the entity to look up
      Returns:
      the requested entry, if found, null otherwise
    • getActionsBySignature

      public List<ActionDBEntry> getActionsBySignature(Predicate actionSignature)
      Look up action(s) by signature.
      Parameters:
      actionSignature -
      Returns:
    • getAllActions

      public final Set<ActionDBEntry> getAllActions()
      Return all actions (primitives and scripts) in the database.
      Returns:
    • getPrimitives

      public final Set<ActionDBEntry> getPrimitives()
      Get primitive set of ActionDBEntries.
      Returns:
    • getScripts

      public final Set<ActionDBEntry> getScripts()
      Get primitive set of ActionDBEntries.
      Returns:
    • removeActionsWithSignature

      protected final void removeActionsWithSignature(Predicate actionSignature)
      Remove all actions with a certain action signature.
      Parameters:
      actionSignature - action signature to remove.
    • removeScripts

      protected void removeScripts()
      Remove all script actions from DB, used to destroy/restart database/gm.
    • getActionSignaturesForName

      public List<Predicate> getActionSignaturesForName(Symbol actionName)