Package FAtiMA.Core.emotionalState
Class EmotionalState
- java.lang.Object
-
- FAtiMA.Core.emotionalState.EmotionalState
-
- All Implemented Interfaces:
java.io.Serializable
public class EmotionalState extends java.lang.Object implements java.io.SerializableImplements the character's emotional state. It contains emotions, mood, and arousal. You cannot create an EmotionalState, since there is one and only one instance of the EmotionalState for the agent. If you want to access it use EmotionalState.GetInstance() method.- Author:
- Joao Dias
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Hashtable<java.lang.String,EmotionDisposition>_emotionDispositionsprotected java.util.Hashtable<java.lang.String,ActiveEmotion>_emotionPoolprotected long_lastTimeprotected Mood_mood
-
Constructor Summary
Constructors Constructor Description EmotionalState()Creates a empty EmotionalState
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ActiveEmotionAddEmotion(BaseEmotion potEm, AgentModel am)Creates and Adds to the emotional state a new ActiveEmotion based on a received BaseEmotion.voidAddEmotionDisposition(EmotionDisposition emotionDisposition)voidClear()Clears all the emotions in the EmotionalStateEmotionalStateclone()voidDecay()Decays all emotions, mood and arousal according to the System TimeActiveEmotionDetermineActiveEmotion(BaseEmotion potEm)Creates a new ActiveEmotion based on a received BaseEmotion.ActiveEmotionGetEmotion(BaseEmotion emotion)ActiveEmotionGetEmotion(java.lang.String emotionKey)Searches for a given emotion in the EmotionalStateEmotionDispositiongetEmotionDisposition(java.lang.String emotionName)java.util.Collection<EmotionDisposition>getEmotionDispositions()java.util.Set<java.lang.String>GetEmotionKeysSet()Gets a set that contains all the keys for the emotionsjava.util.Collection<ActiveEmotion>getEmotionPoolValues()java.util.Iterator<ActiveEmotion>GetEmotionsIterator()Gets an Iterator that allows you to iterate over the set of ActiveEmotions in the agent's emotional statefloatGetMood()Gets a float value that represents the characters mood.ActiveEmotionGetStrongestEmotion()Gets the current strongest emotion (the one with highest intensity) in the character's emotional stateActiveEmotionGetStrongestEmotion(Event event)Gets the current strongest emotion (the one with highest intensity) in the character's emotional state, which was triggered by the received eventvoidRemoveEmotion(ActiveEmotion em)java.lang.StringtoString()Converts the emotional state to a Stringjava.lang.StringtoXml()Converts the emotional state to XML
-
-
-
Field Detail
-
_emotionPool
protected java.util.Hashtable<java.lang.String,ActiveEmotion> _emotionPool
-
_emotionDispositions
protected java.util.Hashtable<java.lang.String,EmotionDisposition> _emotionDispositions
-
_lastTime
protected long _lastTime
-
_mood
protected Mood _mood
-
-
Method Detail
-
clone
public EmotionalState clone()
- Overrides:
clonein classjava.lang.Object
-
AddEmotion
public ActiveEmotion AddEmotion(BaseEmotion potEm, AgentModel am)
Creates and Adds to the emotional state a new ActiveEmotion based on a received BaseEmotion. However, the ActiveEmotion will be created and added to the emotional state only if the final intensity for the emotion surpasses the threshold for the emotion type.- Parameters:
potEm- - the BaseEmotion that creates the ActiveEmotion- Returns:
- the ActiveEmotion created if it was added to the EmotionalState. Otherwise, if the intensity of the emotion was not enough to be added to the EmotionalState, the method returns null
-
DetermineActiveEmotion
public ActiveEmotion DetermineActiveEmotion(BaseEmotion potEm)
Creates a new ActiveEmotion based on a received BaseEmotion. However, the ActiveEmotion will be created only if the final intensity for the emotion surpasses the threshold for the emotion type. Very similar to the method AddEmotion, but this method DOES NOT ADD the emotion to the emotional state. It should only be used to determine the emotion that would be created.- Parameters:
potEm- - the BaseEmotion that creates the ActiveEmotion- Returns:
- the ActiveEmotion created. If the intensity of the emotion was not enough to be created, the method returns null
-
Clear
public void Clear()
Clears all the emotions in the EmotionalState
-
Decay
public void Decay()
Decays all emotions, mood and arousal according to the System Time
-
GetEmotion
public ActiveEmotion GetEmotion(java.lang.String emotionKey)
Searches for a given emotion in the EmotionalState- Parameters:
emotionKey- - a string that corresponds to a hashkey that represents the emotion in the EmotionalState- Returns:
- the found ActiveEmotion if it exists in the EmotionalState, null if the emotion doesn't exist anymore
-
GetEmotion
public ActiveEmotion GetEmotion(BaseEmotion emotion)
-
GetEmotionKeysSet
public java.util.Set<java.lang.String> GetEmotionKeysSet()
Gets a set that contains all the keys for the emotions- Returns:
- the KeySet for all emotions
-
GetEmotionsIterator
public java.util.Iterator<ActiveEmotion> GetEmotionsIterator()
Gets an Iterator that allows you to iterate over the set of ActiveEmotions in the agent's emotional state- Returns:
- an emotion's iterator
-
GetMood
public float GetMood()
Gets a float value that represents the characters mood. 0 represents neutral mood, negative values represent negative mood, positive values represent positive mood (ranged [-10;10])- Returns:
- the agent's mood
-
GetStrongestEmotion
public ActiveEmotion GetStrongestEmotion()
Gets the current strongest emotion (the one with highest intensity) in the character's emotional state- Returns:
- the strongest emotion or null if there is no emotion in the emotional state
-
GetStrongestEmotion
public ActiveEmotion GetStrongestEmotion(Event event)
Gets the current strongest emotion (the one with highest intensity) in the character's emotional state, which was triggered by the received event- Parameters:
event- - the event that caused the emotion that we want to retrieve- Returns:
- the strongest emotion or null if there is no emotion in the emotional state
-
toString
public java.lang.String toString()
Converts the emotional state to a String- Overrides:
toStringin classjava.lang.Object- Returns:
- the converted String
-
toXml
public java.lang.String toXml()
Converts the emotional state to XML- Returns:
- a XML String that contains all information in the emotional state
-
RemoveEmotion
public void RemoveEmotion(ActiveEmotion em)
-
AddEmotionDisposition
public void AddEmotionDisposition(EmotionDisposition emotionDisposition)
-
getEmotionDispositions
public java.util.Collection<EmotionDisposition> getEmotionDispositions()
-
getEmotionDisposition
public EmotionDisposition getEmotionDisposition(java.lang.String emotionName)
-
getEmotionPoolValues
public java.util.Collection<ActiveEmotion> getEmotionPoolValues()
-
-