Navigation
API > API/Plugins > API/Plugins/MLAdapter > API/Plugins/MLAdapter/Agents
Inheritance Hierarchy
- UObjectBase
- UObjectBaseUtility
- UObject
- UMLAdapterAgent
- UMLAdapterAgent_Inference
References
| Module | MLAdapter |
| Header | /Engine/Plugins/AI/MLAdapter/Source/MLAdapter/Public/Agents/MLAdapterAgent.h |
| Include | #include "Agents/MLAdapterAgent.h" |
Syntax
UCLASS&40;Blueprintable, EditInlineNew&41;
class UMLAdapterAgent : public UObject
Remarks
An agent capable of controlling a single avatar (e.g. a Pawn or Controller). Contains sensors for perceiving information about the environment and actuators for taking actions in the game.
Variables
| Type | Name | Description | |
|---|---|---|---|
| FCriticalSection | ActionDurationCS | ||
| float | ActionDurationSeconds | How long should agents wait before they can change their action. | |
| TArray< TObjectPtr< UMLAdapterActuator > > | Actuators | ||
| TSubclassOf< AActor > | AvatarClass | ||
| bool | bActionDurationElapsed | ||
| bool | bEnableActionDuration | If true, then agents won't be able to make a new decision until each action duration has elapsed. | |
| float | CurrentActionDuration | How much time has the current action been executing. | |
| TArray< TObjectPtr< UMLAdapterSensor > > | Sensors | ||
| friend | UMLAdapterSession |
Constructors
| Type | Name | Description | |
|---|---|---|---|
UMLAdapterAgent
(
const FObjectInitializer& ObjectInitializer |
Functions
| Type | Name | Description | |
|---|---|---|---|
| void | Act
(
const float DeltaTime |
Tick all of the agent's actuators. | |
| void | Configure
(
const FMLAdapterAgentConfig& NewConfig |
Setup this agent's avatar, sensors, and actuators. Typically used for agents spawned via RPC. | |
| void | DigestActions
(
FMLAdapterMemoryReader& ValueStream |
Move data into the actuators for the next time Act is called. | |
| void | EnableActionDuration
(
bool bEnable, |
Enable/disable the action durations with the specified time duration in seconds. | |
| void | GetActionSpaceDescription
(
FMLAdapterSpaceDescription& OutSpaceDesc |
Get the overall action space of this agent based on all its actuators. | |
| UMLAdapterActuator * | GetActuator
(
const uint32 ActuatorID |
Get the actuator with the given ID if this agent has it. | |
| TArray< TObjectPtr< UMLAdapterActuator > >::TConstIterator | |||
| FMLAdapter::FAgentID | GetAgentID () |
Get this agent's ID. | |
| AActor * | GetAvatar () |
Get the avatar this agent is controlling. | |
| const FMLAdapterAgentConfig & | GetConfig () |
Get this agent's current config. | |
| const AController * | Get the Controller this agent is controlling. | ||
| AController * | Get the Controller this agent is controlling. | ||
| void | Retrieve all the sensor data from the last time Sense was called. | ||
| void | GetObservationSpaceDescription
(
FMLAdapterSpaceDescription& OutSpaceDesc |
Get the overall observation space of this agent based on all its sensors. | |
| APawn * | GetPawn () |
Get the Pawn this agent is controlling. | |
| const APawn * | GetPawn () |
Get the Pawn this agent is controlling. | |
| float | GetReward () |
If the avatar is a controller, then get the current score from the controller's player state. | |
| TArray< TObjectPtr< UMLAdapterSensor > >::TConstIterator | |||
| UMLAdapterSession & | GetSession () |
Get the session that this agent belongs to. | |
| bool | IsDone () |
The agent is done if its avatar has been destroyed and it can't request a new one. | |
| bool | IsReady () |
Returns true if this agent has an avatar set. | |
| bool | IsSuitableAvatar
(
AActor& InAvatar |
Returns true is the given avatar can be controlled by this agent. | |
| void | OnAvatarDestroyed
(
AActor* DestroyedActor |
When the agent's avatar is destroyed, we need to cleanup callbacks and references to the avatar. | |
| void | OnPawnChanged
(
APawn* NewPawn, |
If the Pawn changed, we need to let all the sensors know. | |
| void | OnPawnControllerChanged
(
APawn* InPawn, |
Will be bound to UGameInstance.OnPawnControllerChanged if current avatar is a pawn or a controller. | |
| bool | RegisterSensor
(
UMLAdapterSensor& Sensor |
Add a sensor to this agent. Returns true if the sensor was successfully added. | |
| void | Sense
(
const float DeltaTime |
Updates all the sensors that are configured as 'IsPolling'. | |
| void | SetAgentID
(
FMLAdapter::FAgentID NewAgentID |
Set this agent's ID to its new ID. | |
| void | Sets the avatar for this agent and all of its sensors and actuators. Registers callbacks. | ||
| void | |||
| void | Think
(
const float DeltaTime |
Decide what action to take based on the current observations. | |
| bool | Resets the action duration flag if it has elapsed. |
Overridden from UObject
| Type | Name | Description | |
|---|---|---|---|
| void | BeginDestroy () |
Shutdown all the sensors and actuators and cleanup references to the avatar. | |
| void | Perform initial setup for blueprint spawned agents. |