API Docs for:
Show:

TUDelft.Gamygdala Class

Defined in: Gamygdala.js:8

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

()

Defined in Gamygdala.js:8

Methods

TUDelft.Gamygdala.appraise

(
  • belief
  • [affectedAgent]
)

Defined in Gamygdala.js:212

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.Belief

    The current event, in the form of a Belief object, to be appraised

  • [affectedAgent] TUDelft.Gamygdala.Agent optional

    The 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]
)

Defined in Gamygdala.js:89

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 Double

    The likelihood of this belief to be true.

  • causalAgentName String

    The agent's name of the causal agent of this belief.

  • affectedGoalNames String

    An array of affected goals' names.

  • goalCongruences Double

    An 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 optional

    Incremental 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
)
TUDelft.Gamygdala.Agent

Defined in Gamygdala.js:25

A facilitator method that creates a new Agent and registers it for you

Parameters:

  • agentName String

    The agent with agentName is created

Returns:

TUDelft.Gamygdala.Agent:

An agent reference to the newly created agent

TUDelft.Gamygdala.createGoalForAgent

(
  • agentName
  • goalName
  • goalUtility
  • isMaintenanceGoal
)
TUDelft.Gamygdala.Goal

Defined in Gamygdala.js:39

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 String

    The agent's name to which the newly created goal has to be added.

  • goalName String

    The goal's name.

  • goalUtility Double

    The goal's utility.

  • isMaintenanceGoal Boolean

    Defines 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:

TUDelft.Gamygdala.Goal:
  • a goal reference to the newly created goal.

TUDelft.Gamygdala.createRelation

(
  • sourceName
  • targetName
  • relation
)

Defined in Gamygdala.js:71

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 String

    The agent who has the relation (the source)

  • targetName String

    The agent who is the target of the relation (the target)

  • relation Double

    The relation (between -1 and 1).

TUDelft.Gamygdala.decayAll

()

Defined in Gamygdala.js:320

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

()

Defined in Gamygdala.js:522

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
)
TUDelft.Gamygdala.Agent

Defined in Gamygdala.js:166

Simple agent getter by name.

Parameters:

  • agentName String

    The name of the agent to be found.

Returns:

TUDelft.Gamygdala.Agent:

null or an agent reference that has the name property equal to the agentName argument

TUDelft.Gamygdala.getGoalByName

(
  • goalName
)
TUDelft.Gamygdala.Goal

Defined in Gamygdala.js:197

Simple goal getter by name.

Parameters:

  • goalName String

    The name of the goal to be found.

Returns:

TUDelft.Gamygdala.Goal:

null or a goal reference that has the name property equal to the goalName argument

TUDelft.Gamygdala.linearDecay

()

Defined in Gamygdala.js:513

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
)

Defined in Gamygdala.js:103

Facilitator method to print all emotional states to the console.

Parameters:

  • gain Boolean

    Whether you want to print the gained (true) emotional states or non-gained (false).

TUDelft.Gamygdala.registerAgent

(
  • agent
)

Defined in Gamygdala.js:155

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:

TUDelft.Gamygdala.registerGoal

(
  • goal
)

Defined in Gamygdala.js:183

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:

TUDelft.Gamygdala.setDecay

(
  • decayFactor
  • decayFunction
)

Defined in Gamygdala.js:127

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 Double

    The decayfactor used. A factor of 1 means no decay, a factor

  • decayFunction Function

    The decay function tobe used. choose between linearDecay or exponentialDecay (see the corresponding methods)

TUDelft.Gamygdala.setGain

(
  • gain
)

Defined in Gamygdala.js:115

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 Double

    The gain value [0 and 20].