Navigation
API > API/Plugins > API/Plugins/MLAdapter
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.
| Name | UMLAdapterAgent |
| Type | class |
| Header File | /Engine/Plugins/AI/MLAdapter/Source/MLAdapter/Public/Agents/MLAdapterAgent.h |
| Include Path | #include "Agents/MLAdapterAgent.h" |
Syntax
UCLASS (Blueprintable, EditInlineNew)
class UMLAdapterAgent : public UObject
Inheritance Hierarchy
- UObjectBase → UObjectBaseUtility → UObject → UMLAdapterAgent
Derived Classes
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
UMLAdapterAgent
(
const FObjectInitializer& ObjectInitializer |
Agents/MLAdapterAgent.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| AgentConfig | FMLAdapterAgentConfig | Agents/MLAdapterAgent.h | ||
| AgentID | FMLAdapter::FAgentID | Agents/MLAdapterAgent.h | ||
| Avatar | TObjectPtr< AActor > | Agents/MLAdapterAgent.h | ||
| bEverHadAvatar | uint32 | True if the agent ever had a Pawn. Otherwise, false. | Agents/MLAdapterAgent.h | |
| bRegisteredForPawnControllerChange | uint32 | True if we have callbacks registered. | Agents/MLAdapterAgent.h | |
| Controller | TObjectPtr< AController > | Agents/MLAdapterAgent.h | ||
| Pawn | TObjectPtr< APawn > | Agents/MLAdapterAgent.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void Act
(
const float DeltaTime |
Tick all of the agent's actuators. | Agents/MLAdapterAgent.h | |
virtual void Configure
(
const FMLAdapterAgentConfig& NewConfig |
Setup this agent's avatar, sensors, and actuators. Typically used for agents spawned via RPC. | Agents/MLAdapterAgent.h | |
virtual void DigestActions
(
FMLAdapterMemoryReader& ValueStream |
Move data into the actuators for the next time Act is called. | Agents/MLAdapterAgent.h | |
void EnableActionDuration
(
bool bEnable, |
Enable/disable the action durations with the specified time duration in seconds. | Agents/MLAdapterAgent.h | |
virtual void GetActionSpaceDescription
(
FMLAdapterSpaceDescription& OutSpaceDesc |
Get the overall action space of this agent based on all its actuators. | Agents/MLAdapterAgent.h | |
UMLAdapterActuator * GetActuator
(
const uint32 ActuatorID |
Get the actuator with the given ID if this agent has it. | Agents/MLAdapterAgent.h | |
TArray< TObjectPtr< UMLAdapterActuator > >::TConstIterator GetActuatorsConstIterator() |
Agents/MLAdapterAgent.h | ||
FMLAdapter::FAgentID GetAgentID() |
Get this agent's ID. | Agents/MLAdapterAgent.h | |
AActor * GetAvatar() |
Get the avatar this agent is controlling. | Agents/MLAdapterAgent.h | |
const FMLAdapterAgentConfig & GetConfig () |
Get this agent's current config. | Agents/MLAdapterAgent.h | |
const AController * GetController () |
Get the Controller this agent is controlling. | Agents/MLAdapterAgent.h | |
AController * GetController () |
Get the Controller this agent is controlling. | Agents/MLAdapterAgent.h | |
void GetObservations
(
FMLAdapterMemoryWriter& Ar |
Retrieve all the sensor data from the last time Sense was called. | Agents/MLAdapterAgent.h | |
virtual void GetObservationSpaceDescription
(
FMLAdapterSpaceDescription& OutSpaceDesc |
Get the overall observation space of this agent based on all its sensors. | Agents/MLAdapterAgent.h | |
| Get the Pawn this agent is controlling. | Agents/MLAdapterAgent.h | ||
| Get the Pawn this agent is controlling. | Agents/MLAdapterAgent.h | ||
virtual float GetReward() |
If the avatar is a controller, then get the current score from the controller's player state. | Agents/MLAdapterAgent.h | |
TArray< TObjectPtr< UMLAdapterSensor > >::TConstIterator GetSensorsConstIterator() |
Agents/MLAdapterAgent.h | ||
UMLAdapterSession & GetSession() |
Get the session that this agent belongs to. | Agents/MLAdapterAgent.h | |
virtual bool IsDone() |
The agent is done if its avatar has been destroyed and it can't request a new one. | Agents/MLAdapterAgent.h | |
bool IsReady() |
Returns true if this agent has an avatar set. | Agents/MLAdapterAgent.h | |
virtual bool IsSuitableAvatar
(
AActor& InAvatar |
Returns true is the given avatar can be controlled by this agent. | Agents/MLAdapterAgent.h | |
virtual bool RegisterSensor
(
UMLAdapterSensor& Sensor |
Add a sensor to this agent. Returns true if the sensor was successfully added. | Agents/MLAdapterAgent.h | |
virtual void Sense
(
const float DeltaTime |
Updates all the sensors that are configured as 'IsPolling'. | Agents/MLAdapterAgent.h | |
virtual void SetAvatar
(
AActor* InAvatar |
Sets the avatar for this agent and all of its sensors and actuators. Registers callbacks. | Agents/MLAdapterAgent.h | |
virtual void Think
(
const float DeltaTime |
Decide what action to take based on the current observations. | Agents/MLAdapterAgent.h | |
bool TryResetActionDuration () |
Resets the action duration flag if it has elapsed. | Agents/MLAdapterAgent.h |
Overridden from UObject
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void BeginDestroy() |
Shutdown all the sensors and actuators and cleanup references to the avatar. | Agents/MLAdapterAgent.h | |
virtual void PostInitProperties() |
Perform initial setup for blueprint spawned agents. | Agents/MLAdapterAgent.h |
Protected
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void OnAvatarDestroyed
(
AActor* DestroyedActor |
When the agent's avatar is destroyed, we need to cleanup callbacks and references to the avatar. | Agents/MLAdapterAgent.h | |
virtual void OnPawnChanged
(
APawn* NewPawn, |
If the Pawn changed, we need to let all the sensors know. | Agents/MLAdapterAgent.h | |
void OnPawnControllerChanged
(
APawn* InPawn, |
Will be bound to UGameInstance.OnPawnControllerChanged if current avatar is a pawn or a controller. | Agents/MLAdapterAgent.h | |
void SetAgentID
(
FMLAdapter::FAgentID NewAgentID |
Set this agent's ID to its new ID. | Agents/MLAdapterAgent.h | |
virtual void ShutDownSensorsAndActuators() |
Agents/MLAdapterAgent.h |