Class TBehavior

DescriptionHierarchyFieldsMethodsProperties

Unit

Behaviors

Declaration

type TBehavior = class(TTenaciousObject)

Description

Base class for all behaviors.

Hierarchy

TBehavior > TTenaciousObject > TPersistent

Fields

 NameDescription
Protected fAccumulatedTime

Total time (in seconds) that the behavior has been active.

Protected fActive

Indicates whether the behavior is currently active. This property is set to True when the procedure Enter is called and set to False when Exit is called.

Protected fBehaviorList

Container of sub-behaviors. This is the key element for enabling behavioral hierarchies.

Protected fBehaviorTime

Time (in seconds) since the last activation. This variable is set to zero when the procedure Enter is called. See also AccumulatedTime.

Protected fInputVariables

Container class for TVariables containing the input variables (TInputVariables). Input variables are defined in the robot definition file (in the definition of the brain) and are variables needed by the behavior (for internal calculations etc.).

Protected fLevel

Hierarchical level of the behavior.

Protected fStateVariables

Container class for TVariables containing the state variables (TStateVariables). State variables are defined in the robot definition file (in the definition of the brain) and are the variables that are used as inputs to the behavior's utility function (UtilityFunction).

Protected fUtility

The behavior's utility value (as generated by fUtilityFunction).

Protected fUtilityFunction

The behavior's utility function (currently restricted to be in the form of a polynomial function).

Methods

Overview

Public constructor Create; override;
Public constructor CreateAndSet(B: TBehavior); virtual;
Public destructor Destroy; override;
Public procedure AddAsStrings(Strings: TStringList);
Public procedure AddUtilityFunctionsAsStrings(Strings: TStringList);
Public procedure AppendUtilityValuesToVector(UtilityVector: TVector);
Public function Copy: TBehavior; virtual;
Public procedure Enter; virtual;
Public procedure Exit; virtual;
Public procedure FindActive(var ActiveID: TIntegerVector; ActiveBehaviorHierarchyPath: TObjectContainer);
Public procedure GenerateRandomUMGenes(Genome: TGenome; Degree: integer; CoefficientRange: real);
Public function GetActive(ActiveID: TIntegerVector; var CurrentLevel: integer): TBehavior;
Public procedure Initialize(Sensors: TSensors; Hormones: THormones); virtual;
Public procedure LoadFromDefinition(ObjDef: TObjectDefinition); virtual;
Public procedure SetLevel(Level: integer);
Public procedure SetUtilityFunction(UtilityFunction: TMathematicalFunction);
Public procedure SetUtilityFunctionFromGenome(Genome: TGenome; var index: integer);
Public procedure Step(TimeStep: real); virtual;
Public procedure UpdateUtility;

Description

Public constructor Create; override;

Constructor

Public constructor CreateAndSet(B: TBehavior); virtual;

Copy constructor. Copies all properties of B and then sets BehaviorTime and AccumulatedTime to zero.

Public destructor Destroy; override;

Destructor

Public procedure AddAsStrings(Strings: TStringList);

Adds the name of the behavior (and any sub-behaviors) as string to a list of strings. Plus signs ("+") are prepended to the name of the behavior to indicate the behavior's hierarchical level. This procedure is called by TBrain.HierarchyAsStrings.

Public procedure AddUtilityFunctionsAsStrings(Strings: TStringList);

Adds all utility functions (including sub-behaviors) as strings to a list of strings. Hierarchical level is indicated by prepending space characters. For clarity, the name of the behavior is appended to the utility function. This procedure is called by TBrain.UtilityFunctionsAsStrings.

Public procedure AppendUtilityValuesToVector(UtilityVector: TVector);

Appends the current values of the utility functions (entire hierarchy) to the supplied vector. This procedure is called by TBrain.GetUtilityValuesAsVector.

Public function Copy: TBehavior; virtual;

Creates a copy of the behavior by calling the copy constructor CreateAndSet.

returns

A copy of the behavior.

Public procedure Enter; virtual;

Procedure called when the behavior is activated. Main purpose of this procedure is to set BehaviorTime to zero and set the property Active to True.

Public procedure Exit; virtual;

Procedure called when the behavior is de-activated (occurs when another behavior is activated). This procedure sets the property Active to False and updates the variable AccumulatedTime by adding the value of BehaviorTime.

Public procedure FindActive(var ActiveID: TIntegerVector; ActiveBehaviorHierarchyPath: TObjectContainer);

Recursive procedure for finding the behavior that is active (or the entire path of behaviors in case of a hierarchical structure of behaviors). This procedure is used by TBrain and should not be called explicitly. Instead, use the property TBrain.ActiveBehavior to get the active behavior during run-time.

Public procedure GenerateRandomUMGenes(Genome: TGenome; Degree: integer; CoefficientRange: real);

Generates random utility functions for this behavior and any sub-behaviors. This procedure is called by TBrain.GenerateRandomGenome.

Public function GetActive(ActiveID: TIntegerVector; var CurrentLevel: integer): TBehavior;

Recursive procedure that returns the active behavior. This procedure is called by TBrain.GetActiveBehavior (use this procedure to get the active behavior).

returns

The currently active behavior.

Public procedure Initialize(Sensors: TSensors; Hormones: THormones); virtual;

Initialization of the behavior. The main purpose of this procedure is to map all input and state variables. This procedure is called automatically by TBrain.Initialize and does not need to be called explicitly.

Public procedure LoadFromDefinition(ObjDef: TObjectDefinition); virtual;

Procedure for processing the definition of a behavior (as parsed from the definition text file). This procedure is automatically called from TBehaviorList.LoadFromDefinition and does not need to be called explicitly.

Public procedure SetLevel(Level: integer);

Sets the hierarchical level of the behavior (sets the value of fLevel).

parameters
Level
is the hierarchical level of the behavior.
Public procedure SetUtilityFunction(UtilityFunction: TMathematicalFunction);

Sets the behavior's utility function. (Currently, only polynomial functions are supported.) Before creating a copy of UtilityFunction, the existing function is destroyed. The user is responsible for freeing the space allocated by UtilityFunction.

Public procedure SetUtilityFunctionFromGenome(Genome: TGenome; var index: integer);

Sets the utility function by extracting polynomial function from the genome (see TUMGene) and calling SetUtilityFunction. This procedure is called by TRobot.DecodeGenome and does not need to be called explicitly.

parameters
Genome
is the agent's genome (see TAgent.Genome).
index
is the index of the gene (TGene) in the genome (TGenome). This parameter gets increment for each call to SetUtilityFunctionFromGenome.
Public procedure Step(TimeStep: real); virtual;

Procedure called in every time step. Currently, this procedure only updates the property BehaviorTime by adding the value of TimeStep. This procedure is called in TBrain.Step and does not need to be called explicitly.

Public procedure UpdateUtility;

Procedure that updates the utility value (fUtility) by evaluating the utility function (any sub-behaviors are also updated). Before evaluating the utility function, all relevant state variables (fStateVariables) are updated as well (see TExternalVariable.Update).

Properties

Overview

Public property AccumulatedTime: real;
Public property Active: Boolean;
Public property BehaviorList: TBehaviorList;
Public property BehaviorTime: real;
Public property InputVariables: TInputVariables;
Public property Level: integer;
Public property StateVariables: TStateVariables;
Public property Utility: real;
Public property UtilityFunction: TMathematicalFunction;

Description

Public property AccumulatedTime: real;

Provides read access to the protected variable fAccumulatedTime.

Public property Active: Boolean;

Provides read access to the protected variable fActive.

Public property BehaviorList: TBehaviorList;

Provides read access to the protected variable fBehaviorList.

Public property BehaviorTime: real;

Provides read access to the protected variable fBehaviorTime.

Public property InputVariables: TInputVariables;

Provides read access to fInputVariables.

Public property Level: integer;

Provides read access to fLevel.

Public property StateVariables: TStateVariables;

Provides read access to fStateVariables.

Public property Utility: real;

Provides read access to fUtility.

Public property UtilityFunction: TMathematicalFunction;

Provides read access to fUtilityFunction.


Generated by PasDoc 0.8.8.3 on 2005-05-28 08:13:49