Class TBrain

DescriptionHierarchyFieldsMethodsProperties

Unit

Brain

Declaration

type TBrain = class(TTenaciousObject)

Description

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

Hierarchy

TBrain > TTenaciousObject > TPersistent

Methods

Overview

Public constructor Create; override;
Public constructor CreateAndSet(Brain: TBrain); virtual;
Public destructor Destroy; override;
Public function Copy: TBrain; virtual;
Public procedure ExitAllActiveBehaviors;
Public procedure FindActiveBehavior; virtual;
Public procedure GenerateRandomGenome(Genome: TGenome; Degree: integer; CoefficientRange: real);
Public function GetActiveBehavior: TBehavior;
Public function GetUtilityValuesAsVector: TVector;
Public procedure HierarchyAsStrings(Strings: TStringList);
Public procedure Initialize(Sensors: TSensors); virtual;
Public procedure LoadFromDefinition(ObjDef: TObjectDefinition); virtual;
Public procedure Step(Motors: TMotors; Dt: real); virtual;
Public procedure UpdateUtilityValues; virtual;
Public procedure UtilityFunctionsAsStrings(Strings: TStringList);

Description

Public constructor Create; override;

Constructor

Public constructor CreateAndSet(Brain: TBrain); virtual;

Copy constructor.

parameters
Brain
is the brain to be copied.
returns

A copy of Brain.

Public destructor Destroy; override;

Destructor

Public function Copy: TBrain; virtual;

Copy method returning a copy of itself by calling the constructor CreateAndSet.

returns

A copy of the brain.

Public procedure ExitAllActiveBehaviors;

Calls the procedure Exit for all behaviors present in the vector ActiveID.

Public procedure FindActiveBehavior; virtual;

Updates the properties ActiveBehavior and ActiveID.

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

Generates a random genome by calling the procedure GenerateRandomUMGenes for each behavior.

parameters
Genome
contains the genes.
Degree
is the polynomial degree of the utility function.
CoefficientRange
is the allowed (symmetric) range of the randomly generated coefficients in the utility function.
Public function GetActiveBehavior: TBehavior;

Get the currently active behavior. This procedure uses the vector ActiveID to locate the active behavior. See also FindActiveBehavior.

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

returns

A vector containing the all utility values.

Public procedure HierarchyAsStrings(Strings: TStringList);

Adds the behavioral hierarchy as strings to a list of strings. To add the strings, this procedure calls TBehaviorList.AddAsStrings.

parameters
Strings
is the list of strings to which the behavioral hierarchy will be added.
Public procedure Initialize(Sensors: TSensors); virtual;

Procedure for initilization purposes. This procedure loops through all behaviors, calling the procedure TBehavior.Initialize for each of them.

parameters
Sensors
provides access to all sensors (needed by some behaviors).
Public 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.

Public 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).

parameters
Motors
contains all motors present in the robot's body.
Dt
is the time step.
Public 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).

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

parameters
Strings
is the list of strings to which the utility functions will be added.

Properties

Overview

Public property ActiveBehavior: TBehavior;
Public property ActiveID: TIntegerVector;
Public property BehaviorList: TBehaviorList;
Public property Hormones: THormones;

Description

Public property ActiveBehavior: TBehavior;

The currently active behavior (the behavior having the highest utility value).

Public 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).

Public property BehaviorList: TBehaviorList;

The list of behaviors (as declared in the definition file).

Public property Hormones: THormones;

Property providing read access to the hormone container object (of type THormones).


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