Class Goal

  • All Implemented Interfaces:
    IGroundable, java.io.Serializable, java.lang.Cloneable
    Direct Known Subclasses:
    ActivePursuitGoal, InterestGoal

    public abstract class Goal
    extends java.lang.Object
    implements IGroundable, java.lang.Cloneable, java.io.Serializable
    abstract goal class used to represent common aspects of Interest goals and ActivePursuit goals.
    Author:
    Joao Dias
    See Also:
    Serialized Form
    • Field Detail

      • IMPORTANCEOFSUCCESS

        public static final java.lang.String IMPORTANCEOFSUCCESS
        See Also:
        Constant Field Values
      • IMPORTANCEOFFAILURE

        public static final java.lang.String IMPORTANCEOFFAILURE
        See Also:
        Constant Field Values
      • goalCounter

        protected static int goalCounter
      • _name

        protected Name _name
      • _key

        protected java.lang.String _key
      • _appliedSubstitutions

        protected java.util.ArrayList<Substitution> _appliedSubstitutions
      • _goalID

        protected int _goalID
      • _baseIOF

        protected int _baseIOF
      • _baseIOS

        protected int _baseIOS
      • _dynamicIOF

        protected Name _dynamicIOF
      • _dynamicIOS

        protected Name _dynamicIOS
    • Constructor Detail

      • Goal

        public Goal()
        Creates a new Empty Goal. Not used directly since its an abstract class
      • Goal

        public Goal​(Name description)
        Creates a new Goal. Not used directly since its an abstract class
        Parameters:
        description - - the goal's name
    • Method Detail

      • getAppliedSubstitutions

        public java.util.ArrayList<Substitution> getAppliedSubstitutions()
      • GenerateGoalStatus

        public java.lang.String GenerateGoalStatus​(java.lang.String status)
        Generates a status description of goal according to the received status. Ex: if the goal is Fight(Luke) and the status is GOALSUCCESS the method returns GOALSUCCESS(Fight,Luke)
        Parameters:
        status - - the goal status, use one of the static status values: Goal.GOALSUCCESS Goal.GOALFAILURE Goal.GOALDROPED ... etc
        Returns:
        status
      • AddCondition

        public abstract void AddCondition​(java.lang.String conditionType,
                                          Condition cond)
        Adds a condition to the goal
        Parameters:
        conditionType - - the type of the condition: success condition, precondition, etc
        cond - - the condition to add
      • CheckIntegrity

        public abstract void CheckIntegrity​(IntegrityValidator val)
                                     throws UnreachableGoalException
        Checks the integrity of the goal. For instance it checks if the goal's success conditions are reachable by at least one action in the domain operators. If not it means that the goal will never be achieve and probably is a typo in the goal's definition (or in the actions file)
        Parameters:
        val - - the validator used to check the goal
        Throws:
        UnreachableGoalException - - thrown if a goal's success conditions can never be achieved because there is no operator with such effects
      • DecreaseImportanceOfFailure

        public void DecreaseImportanceOfFailure​(AgentModel am,
                                                float decr)
        Decreases the ImportanceOfFailure of a goal by a given ammount Used for emotion-focused coping strategies like disengagement
      • getKey

        public java.lang.String getKey()
      • IncreaseImportanceOfFailure

        public void IncreaseImportanceOfFailure​(AgentModel am,
                                                float incr)
        Increases the ImportanceOfFailure of a goal by a given ammount Used for emotion-focused coping strategies
      • DecreaseImportanceOfSuccess

        public void DecreaseImportanceOfSuccess​(AgentModel am,
                                                float decr)
        Decreases the ImportanceOfSuccess of a goal by a given amount Used for emotion-focused coping strategies like disengagement
      • IncreaseImportanceOfSuccess

        public void IncreaseImportanceOfSuccess​(AgentModel am,
                                                float incr)
        Increases the ImportanceOfSuccess of a goal by a fixed ammount Used for emotion-focused coping strategies
      • GetImportanceOfFailure

        public float GetImportanceOfFailure​(AgentModel am)
        Gets the goal's importance of failure
        Returns:
        the importance of failure ranged [0;10]
      • GetImportanceOfSuccess

        public float GetImportanceOfSuccess​(AgentModel am)
        Gets the goal's importance of success
        Returns:
        the importance of success ranged [0;10]
      • getName

        public Name getName()
        Gets the goal's name
        Returns:
        the name of the goal
      • GetActivationEvent

        public Event GetActivationEvent()
        Gets an Event that represents the goal's activation
        Returns:
        an Event that contains a description of the goal's activation
      • GetSuccessEvent

        public Event GetSuccessEvent()
        Gets an Event that represents the goal's success
        Returns:
        an Event that contains a description of the goal's success
      • GetFailureEvent

        public Event GetFailureEvent()
        Gets an Event that represents the goal's failure
        Returns:
        an Event that contains a description of the goal's failure
      • GetCancelEvent

        public Event GetCancelEvent()
      • generateEventDescription

        protected Event generateEventDescription​(short goalEventType)
      • ReplaceUnboundVariables

        public abstract void ReplaceUnboundVariables​(int variableID)
        Replaces all unbound variables in the object by applying a numeric identifier to each one. For example, the variable [x] becomes [x4] if the received ID is 4. Attention, this method modifies the original object.
        Specified by:
        ReplaceUnboundVariables in interface IGroundable
        Parameters:
        variableID - - the identifier to be applied
      • MakeGround

        public abstract void MakeGround​(java.util.ArrayList<Substitution> bindings)
        Applies a set of substitutions to the object, grounding it. Example: Applying the substitution "[X]/John" in the name "Weak([X])" returns "Weak(John)". Attention, this method modifies the original object.
        Specified by:
        MakeGround in interface IGroundable
        Parameters:
        bindings - - A list of substitutions of the type "[Variable]/value"
        See Also:
        Substitution
      • MakeGround

        public abstract void MakeGround​(Substitution subst)
        Applies a set of substitutions to the object, grounding it. Example: Applying the substitution "[X]/John" in the name "Weak([X])" returns "Weak(John)". Attention, this method modifies the original object.
        Specified by:
        MakeGround in interface IGroundable
        Parameters:
        subst - - a substitution of the type "[Variable]/value"
        See Also:
        Substitution
      • isGrounded

        public boolean isGrounded()
        Indicates if the Goal is grounded (no unbound variables in its name and conditions) Example: Stronger(Luke,John) is grounded while Stronger(John,[X]) is not.
        Specified by:
        isGrounded in interface IGroundable
        Returns:
        true if all the goal's conditions and name are grounded, false otherwise
      • SetImportanceOfFailure

        public void SetImportanceOfFailure​(AgentModel am,
                                           float imp)
        Sets the goal's importance of failure
        Parameters:
        imp - - the new importance of failure (ranged [0;10])
      • SetImportanceOfSuccess

        public void SetImportanceOfSuccess​(AgentModel am,
                                           float imp)
        Sets the goal's importance of success
        Parameters:
        imp - - the new importance of success (ranged [0;10])
      • toString

        public java.lang.String toString()
        Converts the Goal to a String
        Overrides:
        toString in class java.lang.Object
        Returns:
        the converted String
      • GroundConditionList

        protected java.util.ArrayList<Condition> GroundConditionList​(java.util.ArrayList<Condition> originalList,
                                                                     java.util.ArrayList<Substitution> bindings)
        Gets a list of conditions, a list of bindings and returns a new list of conditions where the conditions were grounded with the list of received bindings. Defined for internal use of the InterestGoal and ActivePursuitGoal classes
        Parameters:
        originalList - - the list of conditions to ground
        bindings - - a list of substitutions to apply to the condition list
        Returns:
        a list with grounded conditions
        See Also:
        Substitution