TUDelft.Gamygdala Class
This is the main appraisal engine class taking care of interpreting a situation emotionally. Typically you create one instance of this class and then register all agents (emotional entities) to it, as well as all goals.
Constructor
TUDelft.Gamygdala
()
Item Index
Methods
- TUDelft.Gamygdala.appraise
- TUDelft.Gamygdala.appraiseBelief
- TUDelft.Gamygdala.createAgent
- TUDelft.Gamygdala.createGoalForAgent
- TUDelft.Gamygdala.createRelation
- TUDelft.Gamygdala.decayAll
- TUDelft.Gamygdala.exponentialDecay
- TUDelft.Gamygdala.getAgentByName
- TUDelft.Gamygdala.getGoalByName
- TUDelft.Gamygdala.linearDecay
- TUDelft.Gamygdala.printAllEmotions
- TUDelft.Gamygdala.registerAgent
- TUDelft.Gamygdala.registerGoal
- TUDelft.Gamygdala.setDecay
- TUDelft.Gamygdala.setGain
Methods
TUDelft.Gamygdala.appraise
-
belief
-
[affectedAgent]
This method is the main emotional interpretation logic entry point. It performs the complete appraisal of a single event (belief) for all agents (affectedAgent=null) or for only one agent (affectedAgent=true) if affectedAgent is set, then the complete appraisal logic is executed including the effect on relations (possibly influencing the emotional state of other agents), but only if the affected agent (the one owning the goal) == affectedAgent this is sometimes needed for efficiency, if you as a game developer know that particular agents can never appraise an event, then you can force Gamygdala to only look at a subset of agents. Gamygdala assumes that the affectedAgent is indeed the only goal owner affected, that the belief is well-formed, and will not perform any checks, nor use Gamygdala's list of known goals to find other agents that share this goal (!!!)
Parameters:
-
belief
TUDelft.Gamygdala.BeliefThe current event, in the form of a Belief object, to be appraised
-
[affectedAgent]
TUDelft.Gamygdala.Agent optionalThe reference to the agent who needs to appraise the event. If given, this is the appraisal perspective (see explanation above).
TUDelft.Gamygdala.appraiseBelief
-
likelihood
-
causalAgentName
-
affectedGoalNames
-
goalCongruences
-
[isIncremental]
A facilitator method to appraise an event. It takes in the same as what the new Belief(...) takes in, creates a belief and appraises it for all agents that are registered. This method is thus handy if you want to keep all gamygdala logic internal to Gamygdala.
Parameters:
-
likelihood
DoubleThe likelihood of this belief to be true.
-
causalAgentName
StringThe agent's name of the causal agent of this belief.
-
affectedGoalNames
StringAn array of affected goals' names.
-
goalCongruences
DoubleAn array of the affected goals' congruences (i.e., the extend to which this event is good or bad for a goal [-1,1]).
-
[isIncremental]
Boolean optionalIncremental evidence enforces gamygdala to see this event as incremental evidence for (or against) the list of goals provided, i.e, it will add or subtract this belief's likelihood*congruence from the goal likelihood instead of using the belief as "state" defining the absolute likelihood
TUDelft.Gamygdala.createAgent
-
agentName
A facilitator method that creates a new Agent and registers it for you
Parameters:
-
agentName
StringThe agent with agentName is created
Returns:
An agent reference to the newly created agent
TUDelft.Gamygdala.createGoalForAgent
-
agentName
-
goalName
-
goalUtility
-
isMaintenanceGoal
A facilitator method to create a goal for a particular agent, that also registers the goal to the agent and gamygdala. This method is thus handy if you want to keep all gamygdala logic internal to Gamygdala. However, if you want to do more sophisticated stuff (e.g., goals for multiple agents, keep track of your own list of goals to also remove them, appraise events per agent without the need for gamygdala to keep track of goals, etc...) this method will probably be doing too much.
Parameters:
-
agentName
StringThe agent's name to which the newly created goal has to be added.
-
goalName
StringThe goal's name.
-
goalUtility
DoubleThe goal's utility.
-
isMaintenanceGoal
BooleanDefines if the goal is a maintenance goal or not [optional]. The default is that the goal is an achievement goal, i.e., a goal that once it's likelihood reaches true (1) or false (-1) stays that way.
Returns:
- a goal reference to the newly created goal.
TUDelft.Gamygdala.createRelation
-
sourceName
-
targetName
-
relation
A facilitator method to create a relation between two agents. Both source and target have to exist and be registered with this Gamygdala instance. This method is thus handy if you want to keep all gamygdala logic internal to Gamygdala.
Parameters:
-
sourceName
StringThe agent who has the relation (the source)
-
targetName
StringThe agent who is the target of the relation (the target)
-
relation
DoubleThe relation (between -1 and 1).
TUDelft.Gamygdala.decayAll
()
This method decays for all registered agents the emotional state and relations. It performs the decay according to the time passed, so longer intervals between consecutive calls result in bigger clunky steps. Typically this is called automatically when you use startDecay(), but you can use it yourself if you want to manage the timing. This function is keeping track of the millis passed since the last call, and will (try to) keep the decay close to the desired decay factor, regardless the time passed So you can call this any time you want (or, e.g., have the game loop call it, or have e.g., Phaser call it in the plugin update, which is default now). Further, if you want to tweak the emotional intensity decay of individual agents, you should tweak the decayFactor per agent not the "frame rate" of the decay (as this doesn't change the rate).
TUDelft.Gamygdala.exponentialDecay
()
You can set Gamygdala to use this function for all emotion decay by calling setDecay() and passing this function as second parameter. This function is not to be called directly.
TUDelft.Gamygdala.getAgentByName
-
agentName
Simple agent getter by name.
Parameters:
-
agentName
StringThe name of the agent to be found.
Returns:
null or an agent reference that has the name property equal to the agentName argument
TUDelft.Gamygdala.getGoalByName
-
goalName
Simple goal getter by name.
Parameters:
-
goalName
StringThe name of the goal to be found.
Returns:
null or a goal reference that has the name property equal to the goalName argument
TUDelft.Gamygdala.linearDecay
()
You can set Gamygdala to use this function for all emotion decay by calling setDecay() and passing this function as second parameter. This function is not to be called directly.
TUDelft.Gamygdala.printAllEmotions
-
gain
Facilitator method to print all emotional states to the console.
Parameters:
-
gain
BooleanWhether you want to print the gained (true) emotional states or non-gained (false).
TUDelft.Gamygdala.registerAgent
-
agent
For every entity in your game (usually NPC's, but can be the player character too) you have to first create an Agent object and then register it using this method. Registering the agent makes sure that Gamygdala will be able to emotionally interpret incoming Beliefs about the game state for that agent.
Parameters:
-
agent
TUDelft.Gamygdala.AgentThe agent to be registered
TUDelft.Gamygdala.registerGoal
-
goal
For every goal that NPC's or player characters can have you have to first create a Goal object and then register it using this method. Registering the goals makes sure that Gamygdala will be able to find the correct goal references when a Beliefs about the game state comes in.
Parameters:
-
goal
TUDelft.Gamygdala.GoalThe goal to be registered.
TUDelft.Gamygdala.setDecay
-
decayFactor
-
decayFunction
Sets the decay factor and function for emotional decay. It sets the decay factor and type for emotional decay, so that an emotion will slowly get lower in intensity. Whenever decayAll is called, all emotions for all agents are decayed according to the factor and function set here.
Parameters:
-
decayFactor
DoubleThe decayfactor used. A factor of 1 means no decay, a factor
-
decayFunction
FunctionThe decay function tobe used. choose between linearDecay or exponentialDecay (see the corresponding methods)
TUDelft.Gamygdala.setGain
-
gain
Facilitator to set the gain for the whole set of agents known to TUDelft.Gamygdala. For more realistic, complex games, you would typically set the gain for each agent type separately, to finetune the intensity of the response.
Parameters:
-
gain
DoubleThe gain value [0 and 20].