Previous: , Up: AI   [Contents][Index]


2.9 Utility Module

Component: UtilityModule

Utility Module is a decision-making machine which compares your Directive’s Utility Graphs and activates Behavior Sequencer components to orchestrate complex behavior. The graphs are compared at their current Valence (X axis) to get their Utility (Y axis). It’s most common use is for AI units, but it can make decisions for a variety of systems in your game. It chooses the Directive with the currently highest Utility. To use, add a Utility Module and at least one Behavior Sequencer component. Next, specify multiple Directives which the Utility Module can choose from. Then, create a Utility Graph which represents the level of desire from low desire on the left to high desire on the right. The Valence tells Utility Module what point on the graph we are currently on. The Valence has a Change Per Sec which allows the graph to change over time automatically.

Field of UtilityModule: string uniqueIdentifier

A unique string wich identifies this particular Utility Module from all others. Used for serialization only

Field of UtilityModule: string personalityName

The name of this personality that will be displayed to the player

IMGUI Settings

Field of UtilityModule: Rect guiArea

Normalized viewport rectangle which controls the part of the screen which is taken up by the GUI box for this Utility AI. Numbers are a percentage of screen coordinates. Only applies to immediate mode GUI

Default value: new Rect(.3f, .3f, .3f, .3f)

UGUI Settings

Field of UtilityModule: InputField nameDisplay

If we’re using UGUI (as opposed to immediate mode) assign this to display the name of the personality for this AI

Available Messages

Message on UtilityModule: SatisfyDirective (string)

Applies the ’Satisfaction Value’ of the given directive so that the valence of that directive can change

Argument: The name of the directive we wish to satisfy. This moves the current X position on the Utility Graph ( Valence = Satisfaction Value + Valence). To satisfy completely, set Satsifaction Value to -1. To max out the graph, set Satsifaction Value to + 1.

Message on UtilityModule: FailDirective (string)

Causes the Utility AI to fail a given directive, allowing it to re-evaluate it’s directives and optionally start a sequence resultant from that failure.

Argument: The name of the Directive we wish to fail.

Message on UtilityModule: FailCurrentDirective ()

Causes the AI to start the failure sequence associated with the currently active directive, if any, and choose another directive if possible

Message on UtilityModule: SelectDirective (string)

Sets one of the Directives to be selected, so that SatisfySelected knows which Directive to satisfy

Argument: The Name of the Directive we wish to select.

Message on UtilityModule: SatisfySelected (float)

Satisfy the Directive we selected by a specific amount. This is added to the Valence, which is a number between 0 and 1 indicating the current X position on the Utility Graph for the selected Directive. Select a Directive by sending the SelectDirective message

Argument: How much should we add to the Valence? Negative numbers satisfy.

Message on UtilityModule: Decide ()

Causes the AI to re-evaluate it’s directives and immediately initiate a Behavior Sequencer, even if that sequence is already running.

Message on UtilityModule: Save ()

Saves the current state of this Utility Module based on it’s unique identifier

Message on UtilityModule: Load ()

Loads the previous state of the Utilitymodule based on it’s unique identifier

Message on UtilityModule: RandomizeIdentifier ()

Finds an unused random number and uses it as the new Unique Identifier for this Utility Module

Message on UtilityModule: SetUniqueIdentifier (string)

Assigns a new Unique Identifier to this Utility Module

Argument: The new Unique Identifier that you wish to use for this Utility Module.

Message on UtilityModule: SetPersonalityName ()

Assigns a new Personality Name to this Utility AI, which can be displayed as part of the AI’s

Message on UtilityModule: OpenMenu ()

Opens the IMGUI for this AI

Message on UtilityModule: CloseMenu ()

Closes the IMGUI for this AI

Message on UtilityModule: ToggleMenu ()

Toggles the IMGUI for this AI

Field of UtilityModule: string uniqueIdentifier

A unique string wich identifies this particular Utility Module from all others. Used for serialization only

Field of UtilityModule: string personalityName

The name of this personality that will be displayed to the player

IMGUI Settings

Field of UtilityModule: Rect guiArea

Normalized viewport rectangle which controls the part of the screen which is taken up by the GUI box for this Utility AI. Numbers are a percentage of screen coordinates. Only applies to immediate mode GUI

Default value: new Rect(.3f, .3f, .3f, .3f)

UGUI Settings

Field of UtilityModule: InputField nameDisplay

If we’re using UGUI (as opposed to immediate mode) assign this to display the name of the personality for this AI

Available Messages

Message on UtilityModule: SatisfyDirective (string)

Applies the ’Satisfaction Value’ of the given directive so that the valence of that directive can change

Argument: The name of the directive we wish to satisfy. This moves the current X position on the Utility Graph ( Valence = Satisfaction Value + Valence). To satisfy completely, set Satsifaction Value to -1. To max out the graph, set Satsifaction Value to + 1.

Message on UtilityModule: FailDirective (string)

Causes the Utility AI to fail a given directive, allowing it to re-evaluate it’s directives and optionally start a sequence resultant from that failure.

Argument: The name of the Directive we wish to fail.

Message on UtilityModule: FailCurrentDirective ()

Causes the AI to start the failure sequence associated with the currently active directive, if any, and choose another directive if possible

Message on UtilityModule: SelectDirective (string)

Sets one of the Directives to be selected, so that SatisfySelected knows which Directive to satisfy

Argument: The Name of the Directive we wish to select.

Message on UtilityModule: SatisfySelected (float)

Satisfy the Directive we selected by a specific amount. This is added to the Valence, which is a number between 0 and 1 indicating the current X position on the Utility Graph for the selected Directive. Select a Directive by sending the SelectDirective message

Argument: How much should we add to the Valence? Negative numbers satisfy.

Message on UtilityModule: Decide ()

Causes the AI to re-evaluate it’s directives and immediately initiate a Behavior Sequencer, even if that sequence is already running.

Message on UtilityModule: Save ()

Saves the current state of this Utility Module based on it’s unique identifier

Message on UtilityModule: Load ()

Loads the previous state of the Utilitymodule based on it’s unique identifier

Message on UtilityModule: RandomizeIdentifier ()

Finds an unused random number and uses it as the new Unique Identifier for this Utility Module

Message on UtilityModule: SetUniqueIdentifier (string)

Assigns a new Unique Identifier to this Utility Module

Argument: The new Unique Identifier that you wish to use for this Utility Module.

Message on UtilityModule: SetPersonalityName ()

Assigns a new Personality Name to this Utility AI, which can be displayed as part of the AI’s

Message on UtilityModule: OpenMenu ()

Opens the IMGUI for this AI

Message on UtilityModule: CloseMenu ()

Closes the IMGUI for this AI

Message on UtilityModule: ToggleMenu ()

Toggles the IMGUI for this AI


Previous: , Up: AI   [Contents][Index]