Class AAbstractTrainer

class AAbstractTrainer : public AController

An abstract class representing a controller that trains an NPC using Reinforcement Learning.

Note

This class is designed to be subclassed in C++ or Blueprint to implement the specific training logic for an NPC.

Note

This class is designed to be used in conjunction with the AbstractEnvironment class.

Subclassed by ABlueprintTrainer

Public Functions

AAbstractTrainer()

Construct a new AAbstractTrainer object.

bool Initialize(int EnvId, int AgentId)

Initialize this agent after play has begun.

Parameters:
  • EnvId[in] The ID of the environment this agent is in.

  • AgentId[in] The ID of this agent in the environment.

inline virtual float ComputeReward()

Collect a reward from the agent’s immediate environment.

Note

This function must be implemented by a subclass.

Returns:

float representing the agents reward

inline virtual EAgentTrainingStatus ComputeStatus()

Check if agent is in a terminal state.

Note

This function must be implemented by a subclass.

Returns:

The status of the agent which informs whether it is still running, or why it stopped.

inline virtual void GetInfo(TMap<FString, FString> &Info)

Get the Info output of the agent.

Parameters:

Info[out] A mapping representing non-observation details about the environment.

EAgentTrainingStatus GetTrainingStatus()

Get the last computed training status.

Returns:

The last computed training status.

ETrainingMsgStatus GetTrainingMsgStatus()

Get whether the agent has finished, and if it has sent a final state update noting that it is finished.

Returns:

An enum tracking whether the environment has sent a final state update after ending.

void SetTrainingStatus(EAgentTrainingStatus NewStatus)

Set the Agent’s Training Status.

Parameters:

NewStatus[in] The new status to set

void SetTrainingMsgStatus(ETrainingMsgStatus NewStatus)

Set the Agent’s Training Message Status.

Parameters:

NewStatus[in] The new status to set

bool IsDone() const

Does this agent need resetting (either Truncated or Complete)

Returns:

true iff the agent needs resetting

void Reset()

Reset the agent.

Collect initial observations of the environment after resetting in the process.

inline virtual void ResetTrainer()

Reset any per Episode properties of this Trainer.

Note

This function must be implemented by a subclass.

inline void IncrementStep()

increment the step count for this episode.

This is used to determine when to request a new action from the brain.

inline void ResetStep()

Reset the step count to 0.

This is used to determine when to request a new action from the brain.

virtual bool IsDecisionStep(int StepToCheck)

Check whether a specific step will require a brain decision.

Parameters:

StepToCheck – the timestep to check

Returns:

true iff the agent should be requesting a decision

virtual bool IsDecisionStep()

If the current step is a decision step, as defined by the step frequency.

Returns:

true iff the current step is a decision step

virtual bool IsActionStep()

Check if brain has an action, and it’s an action step.

Returns:

true iff the agent should take an action this step

void Act(const FAction &Action)

The Agent retrieves an action from the brain before taking it.

Parameters:

Action[in] The action to take

FTrainerState Think()

Update the state of the agent.

This checks if the agent is done, what it’s reward should be and does any observation collection before requesting a decision

Returns:

The state of the agent after the update

bool IsRunning()

Check with brain if can act and set agent state accordingly.

Returns:

The state of the agent after the update

Public Members

FTrainerState State = FTrainerState()

The current state of the agent.

UInteractionManager *InteractionManager = CreateDefaultSubobject<UInteractionManager>(TEXT(“InteractionManager”))

An Object for managing the Interactions of the agent and the environment.

TArray<UAbstractObserver*> Observers

List of observers that collect observations for the agent.

TArray<UActuator*> Actuators

List of actuators that execute actions for the agent.

EValidationType Validation = EValidationType::FAIL

The type of validation to perform on this agent.

Fail means agent is skipped on any error. Warning means just warn about non-fatal errors. Set to No Validation to skip validation

bool bTakeActionBetweenDecisions = true

If true the agent will repeat its last action each step between decision requests.

int Step = 0

The current step of the agent.

bool bUseCustomName = false

The name of the agent, used for logging, and grouping agents in rllib.

FString Name

The name of the agent, used for logging, and grouping agents in rllib.

int DecisionRequestFrequency = 5

The number of steps between requests for new actions.

If this is different across agents it may cause issues training in some frameworks (e.g. Stable Baselines 3).

bool bAbstractSettingsVisibility = true

Whether settings in this class are visible in the editor for child classes.

Set to False to hide those settings.

FTrainerDefinition TrainerDefn

The definition of the agent.

Related pages

  • Visit the Schola product page for download links and more information.

Looking for more documentation on GPUOpen?

AMD GPUOpen software blogs

Our handy software release blogs will help you make good use of our tools, SDKs, and effects, as well as sharing the latest features with new releases.

GPUOpen Manuals

Don’t miss our manual documentation! And if slide decks are what you’re after, you’ll find 100+ of our finest presentations here.

AMD GPUOpen Performance Guides

The home of great performance and optimization advice for AMD RDNA™ 2 GPUs, AMD Ryzen™ CPUs, and so much more.

Getting started: AMD GPUOpen software

New or fairly new to AMD’s tools, libraries, and effects? This is the best place to get started on GPUOpen!

AMD GPUOpen Getting Started Development and Performance

Looking for tips on getting started with developing and/or optimizing your game, whether on AMD hardware or generally? We’ve got you covered!

AMD GPUOpen Technical blogs

Browse our technical blogs, and find valuable advice on developing with AMD hardware, ray tracing, Vulkan®, DirectX®, Unreal Engine, and lots more.

Find out more about our software!

AMD GPUOpen Effects - AMD FidelityFX technologies

Create wonder. No black boxes. Meet the AMD FidelityFX SDK!

AMD GPUOpen Samples

Browse all our useful samples. Perfect for when you’re needing to get started, want to integrate one of our libraries, and much more.

AMD GPUOpen developer SDKs

Discover what our SDK technologies can offer you. Query hardware or software, manage memory, create rendering applications or machine learning, and much more!

AMD GPUOpen Developer Tools

Analyze, Optimize, Profile, Benchmark. We provide you with the developer tools you need to make sure your game is the best it can be!