| Description | Hierarchy | Fields | Methods | Properties |
type TBrain = class(TTenaciousObject)
Base class implementing a robotic brain (using utility values for behavior selection). TBrain provides all functionality needed for selecting behaviors based on their utility. When implementing a custom brain (inheriting from TBrain) be sure to override all virtual methods in this class.
Together with the class TBody, TBrain constitutes the fundamental part of a physical robot (TRobot).
Below follows an example of a robotic brain having five different behaviors: (B1) navigate, (B2) avoidance obstacles, (B3) maintain energy, (B3.1) locate corner, and (B3.2) charge battery, where B3.1 and B3.2 are sub-behaviors of B3.
|
Figure 1: Structure of the robotic brain defined in Table 1.
|
Table 1: Example definition of a robotic brain having five behaviors.
|
object Brain: TBrain object Hormones: THormones object Fear: THormone MinimumLevel = 0.0 MaximumLevel = 1.0 end object Hunger: THormone MinimumLevel = 0.0 MaximumLevel = 1.0 end object InverseSatiation: THormone MinimumLevel = 0.0 MaximumLevel = 1.0 end end #Hormones object Behaviors: TBehaviorList Level = 1 object Navigation: TNavigationBehavior MinAngle = -0.2618 MaxAngle = 0.2618 NavigationMotorOutput = 5.0 TimeBetweenDirectionChanges = 4.0 MaxTurnTime = 0.5 MaxTurnOutput = 4.0 object StateVariables: TStateVariables object StateVariable1: TExternalVariable StateVariableType = 'svtExternal' CorrespondingSensorName = 'LaserRangeFinder1' ReadingProcedure = 'rpAverage' end object StateVariable2: TInternalPhysicalVariable CorrespondingSensorName = 'BatterySensor1' ReadingProcedure = 'rpSinglePixel' Pixel = 1 1 end end end #Navigation object ObstacleAvoidance: TObstacleAvoidance MinDist = 0.5 TurnMotorOutput = 6.0 object InputVariables: TInputVariables object InputVariable1: TSensorVariable CorrespondingSensorName = 'LaserRangeFinder1' end end object StateVariables: TStateVariables object StateVariable1: TExternalVariable StateVariableType = 'svtExternal' CorrespondingSensorName = 'LaserRangeFinder1' ReadingProcedure = 'rpAverage' end object StateVariable2: TInternalAbstractVariable StateVariableType = 'svtInternalAbstract' CorrespondingHormoneName = 'Fear' end object StateVariable3: TInternalPhysicalVariable CorrespondingSensorName = 'BatterySensor1' ReadingProcedure = 'rpSinglePixel' Pixel = 1 1 end end end #ObstacleAvoidance object EnergyMaintenance: TEnergyMaintenance object StateVariables: TStateVariables object StateVariable1: TExternalVariable StateVariableType = 'svtExternal' CorrespondingSensorName = 'LaserRangeFinder1' ReadingProcedure = 'rpAverage' end object StateVariable2: TInternalAbstractVariable StateVariableType = 'svtInternalAbstract' CorrespondingHormoneName = 'Hunger' end object StateVariable3: TInternalPhysicalVariable CorrespondingSensorName = 'BatterySensor1' ReadingProcedure = 'rpSinglePixel' Pixel = 1 1 end end object BehaviorList1: TBehaviorList Level = 2 object LocateCorner: TLocateCornerBehavior TurnMotorOutput = 11.0 ApproachMotorOutput = 6.0 StopDistance = 0.4 object StateVariables: TStateVariables object StateVariable1: TExternalVariable StateVariableType = 'svtExternal' CorrespondingSensorName = 'IRDetector1' ReadingProcedure = 'rpSinglePixel' Pixel = 1 1 end object StateVariable2: TInternalPhysicalVariable CorrespondingSensorName = 'BatterySensor1' ReadingProcedure = 'rpSinglePixel' Pixel = 1 1 end end end #LocateCorner object ChargingBehavior: TChargingBehavior CorrespondingBatteryName = 'Battery' MaximumChargingDistance = 0.5 object InputVariables: TInputVariables object InputVariable1: TSensorVariable CorrespondingSensorName = 'IRDetector1' end end object StateVariables: TStateVariables object StateVariable1: TInternalAbstractVariable StateVariableType = 'svtInternalAbstract' CorrespondingHormoneName = 'InverseSatiation' end end end #ChargingBehavior end #BehaviorList1 end #EnergyMaintenance end #Behaviors end |
![]() |
constructor Create; override; |
![]() |
constructor CreateAndSet(Brain: TBrain); virtual; |
![]() |
destructor Destroy; override; |
![]() |
function Copy: TBrain; virtual; |
![]() |
procedure ExitAllActiveBehaviors; |
![]() |
procedure FindActiveBehavior; virtual; |
![]() |
procedure GenerateRandomGenome(Genome: TGenome; Degree: integer; CoefficientRange: real); |
![]() |
function GetActiveBehavior: TBehavior; |
![]() |
function GetUtilityValuesAsVector: TVector; |
![]() |
procedure HierarchyAsStrings(Strings: TStringList); |
![]() |
procedure Initialize(Sensors: TSensors); virtual; |
![]() |
procedure LoadFromDefinition(ObjDef: TObjectDefinition); virtual; |
![]() |
procedure Step(Motors: TMotors; Dt: real); virtual; |
![]() |
procedure UpdateUtilityValues; virtual; |
![]() |
procedure UtilityFunctionsAsStrings(Strings: TStringList); |
![]() |
constructor Create; override; |
Constructor
![]() |
constructor CreateAndSet(Brain: TBrain); virtual; |
Copy constructor.
A copy of Brain.
![]() |
destructor Destroy; override; |
Destructor
![]() |
function Copy: TBrain; virtual; |
Copy method returning a copy of itself by calling the constructor CreateAndSet.
A copy of the brain.
![]() |
procedure ExitAllActiveBehaviors; |
Calls the procedure Exit for all behaviors present in the vector ActiveID.
![]() |
procedure FindActiveBehavior; virtual; |
Updates the properties ActiveBehavior and ActiveID.
![]() |
procedure GenerateRandomGenome(Genome: TGenome; Degree: integer; CoefficientRange: real); |
Generates a random genome by calling the procedure GenerateRandomUMGenes for each behavior.
![]() |
function GetActiveBehavior: TBehavior; |
Get the currently active behavior. This procedure uses the vector ActiveID to locate the active behavior. See also FindActiveBehavior.
![]() |
function GetUtilityValuesAsVector: TVector; |
Generate a vector containing the utility values of all behaviors. To fill the vector with values, this function loops through all behaviors, calling the function TBehavior.AppendUtilityValuesToVector. Note that the caller is responsible for freeing the space allocated by the resulting vector.
A vector containing the all utility values.
![]() |
procedure HierarchyAsStrings(Strings: TStringList); |
Adds the behavioral hierarchy as strings to a list of strings. To add the strings, this procedure calls TBehaviorList.AddAsStrings.
![]() |
procedure Initialize(Sensors: TSensors); virtual; |
Procedure for initilization purposes. This procedure loops through all behaviors, calling the procedure TBehavior.Initialize for each of them.
![]() |
procedure LoadFromDefinition(ObjDef: TObjectDefinition); virtual; |
Procedure for processing the definition of a brain (as parsed from the definition text file). This procedure is automatically called from link(Robot.TRobot).LoadFromFile and does not need to be called explicitly.
![]() |
procedure Step(Motors: TMotors; Dt: real); virtual; |
Procedure called every time step and is used for activating the behavior having the highest utility value and calling its Step procedure. In case the active behavior is of the type TMotorBehavior, the procedure TransferMotorSignals is also called. This procedure is called from TRobotSimulation.Step (if the simulated agent is of the type TRobot).
![]() |
procedure UpdateUtilityValues; virtual; |
Updates the utility value associated with each behavior. This procedure is called (by default) from TRobotSimulation.Step (if the simulated agent is of the type TRobot).
![]() |
procedure UtilityFunctionsAsStrings(Strings: TStringList); |
Adds the utility function associated with each behavior as a string to a list of strings. This procedure loops through all behaviors and calls TBehavior.AddUtilityFunctionsAsStrings for each behavior.
![]() |
property ActiveBehavior: TBehavior; |
![]() |
property ActiveID: TIntegerVector; |
![]() |
property BehaviorList: TBehaviorList; |
![]() |
property Hormones: THormones; |
![]() |
property ActiveBehavior: TBehavior; |
The currently active behavior (the behavior having the highest utility value).
![]() |
property ActiveID: TIntegerVector; |
Index of the currently active behavior (ActiveBehavior). In case the active behavior is part of a hierarchical structure, the entire path is returned in the vector. For example, looking at Figure 1 in TBrain, if behavior B2 is active, the vector will contain a single element (the index 2). If behavior B3.2 is active, the vector will contain two elements (3,2).
![]() |
property BehaviorList: TBehaviorList; |
The list of behaviors (as declared in the definition file).
![]() |
property Hormones: THormones; |
Property providing read access to the hormone container object (of type THormones).