Skip to content

Class UAbstractGymConnector

Class UAbstractGymConnector

  • Defined in File AbstractGymConnector.h

Inheritance Relationships

Base Type

  • public UObject

Derived Types

class UAbstractGymConnector : public UObject

Source: Source/Schola/Training/Public/GymConnectors/AbstractGymConnector.h

Dependencies: FInitialState, FTrainingDefinition, FTrainingReset, FTrainingState, FTrainingStateUpdate, FTrainingStep, IBaseScholaEnvironment, IScholaEnvironment

An abstract class for connectors between Unreal Engine and gym environments.

class provides the basic structure and functionality for connecting Unreal Engine environments with external gym environments for training purposes.

Subclassed by UExternalGymConnector, UManualGymConnector


Public Functions

SymbolDetails
UAbstractGymConnectorConstructor for the abstract gym connector.
~UAbstractGymConnectorDestructor for the gym connector.
InitInitialize this gym connector with training definitions.
InitInitialize this gym connector by collecting and setting up environments.
SetStatusSet the operational status of the connector.
SubmitStateSubmit the current training state to the external training system.
SubmitStateWithInitialStateSubmit both training state and initial state (for environments that reset).
SubmitInitialStateSubmit only the initial state (for reset-only operations).
HandleStepHandle a step update by applying actions to environments.
HandleResetHandle a reset update by resetting specified environments.
ResolveEnvironmentStateUpdateResolve the environment state update.
UpdateConnectorStatusUpdate the connector status based on a state update.
CheckForStartCheck if the connector is ready to start.
IsRunningGet if the connector is running.
IsNotStartedGet if the connector is closed.
CollectEnvironmentsCollect all environment objects in the current world.
PrepareEnvironmentsPrepare environments for training by initializing and storing them.
GetCompletedEnvironmentIdsGet the IDs of environments that have completed their episodes.
StepExecute one training step across all environments.
StepExecute one training step and retrieve the resulting states.
GetAutoResetTypeGet the auto-reset behavior for this connector.

UAbstractGymConnector

UAbstractGymConnector()

Constructor for the abstract gym connector.

Initializes the connector with default values.

Source: Source/Schola/Training/Public/GymConnectors/AbstractGymConnector.h

Implementation: Source/Schola/Training/Private/GymConnectors/AbstractGymConnector.cpp


~UAbstractGymConnector

~UAbstractGymConnector()

Destructor for the gym connector.

Source: Source/Schola/Training/Public/GymConnectors/AbstractGymConnector.h

Implementation: Source/Schola/Training/Private/GymConnectors/AbstractGymConnector.cpp

Init

virtual void Init(const FTrainingDefinition &AgentDefinitions)

Initialize this gym connector with training definitions.

Sets up communication channels and prepares the connector for training. Override this in derived classes to implement specific initialization logic.

Parameters

AgentDefinitions – [in] The definitions of the agents and environments that will be trained.

#DirectionNameTypeDescription
1AgentDefinitionsconst FTrainingDefinition &The definitions of the agents and environments that will be trained.

Attributes: virtual

Source: Source/Schola/Training/Public/GymConnectors/AbstractGymConnector.h

Implementation: Source/Schola/Training/Private/GymConnectors/AbstractGymConnector.cpp

Init

void Init(
const TArray<TScriptInterface<IBaseScholaEnvironment>> &InEnvironments)

Initialize this gym connector by collecting and setting up environments.

Gathers environment definitions and calls the other Init function.

Parameters

InEnvironments – [in] Array of environment interfaces to train.

#DirectionNameTypeDescription
1AgentDefinitionsconst FTrainingDefinition &The definitions of the agents and environments that will be trained.

Attributes: virtual

Source: Source/Schola/Training/Public/GymConnectors/AbstractGymConnector.h

Implementation: Source/Schola/Training/Private/GymConnectors/AbstractGymConnector.cpp

SetStatus

void SetStatus(EConnectorStatus NewStatus)

Set the operational status of the connector.

Also broadcasts appropriate delegates when status changes.

Parameters

NewStatus – [in] The new status to set.

#DirectionNameTypeDescription
1NewStatusEConnectorStatusThe new status to set.

Source: Source/Schola/Training/Public/GymConnectors/AbstractGymConnector.h

Implementation: Source/Schola/Training/Private/GymConnectors/AbstractGymConnector.cpp

SubmitState

inline virtual void SubmitState(const FTrainingState &InTrainingState)

Submit the current training state to the external training system.

Must be implemented by derived classes to handle state submission.

Parameters

InTrainingState – [in] The state containing observations, rewards, and done flags.

#DirectionNameTypeDescription
1InTrainingStateconst FTrainingState &The state containing observations, rewards, and done flags.

Attributes: inline, virtual

Source: Source/Schola/Training/Public/GymConnectors/AbstractGymConnector.h

SubmitStateWithInitialState

inline virtual void
SubmitStateWithInitialState(const FTrainingState &InTrainingState,
const FInitialState &InInitialAgentStates)

Submit both training state and initial state (for environments that reset).

Must be implemented by derived classes.

Parameters

  • InTrainingState – [in] The current training state.

  • InInitialAgentStates – [in] The initial states for reset environments.

#DirectionNameTypeDescription
1InTrainingStateconst FTrainingState &The current training state.
2InInitialAgentStatesconst FInitialState &The initial states for reset environments.

Attributes: inline, virtual

Source: Source/Schola/Training/Public/GymConnectors/AbstractGymConnector.h

SubmitInitialState

inline virtual void
SubmitInitialState(const FInitialState &InInitialAgentStates)

Submit only the initial state (for reset-only operations).

Must be implemented by derived classes.

Parameters

InInitialAgentStates – [in] The initial states for reset environments.

#DirectionNameTypeDescription
1InInitialAgentStatesconst FInitialState &The initial states for reset environments.

Attributes: inline, virtual

Source: Source/Schola/Training/Public/GymConnectors/AbstractGymConnector.h

HandleStep

void HandleStep(const FTrainingStep &InState, FTrainingState &OutTrainingState,
FInitialState &OutInitialState)

Handle a step update by applying actions to environments.

Parameters

  • InState – [in] The step data containing actions for each environment.

  • OutTrainingState – [out] The resulting training state after the step.

  • OutInitialState – [out] The initial states for any environments that reset.

#DirectionNameTypeDescription
1InStateconst FTrainingStep &The step data containing actions for each environment.
2OutTrainingStateFTrainingState &The resulting training state after the step.
3OutInitialStateFInitialState &The initial states for any environments that reset.

Source: Source/Schola/Training/Public/GymConnectors/AbstractGymConnector.h

Implementation: Source/Schola/Training/Private/GymConnectors/AbstractGymConnector.cpp

HandleReset

void HandleReset(const FTrainingReset &InReset,
FTrainingState &OutTrainingState,
FInitialState &OutInitialState)

Handle a reset update by resetting specified environments.

Parameters

  • InReset – [in] The reset data specifying which environments to reset.

  • OutTrainingState – [out] The resulting training state (empty for pure resets).

  • OutInitialState – [out] The initial states after reset.

#DirectionNameTypeDescription
1InResetconst FTrainingReset &The reset data specifying which environments to reset.
2OutTrainingStateFTrainingState &The resulting training state (empty for pure resets).
3OutInitialStateFInitialState &The initial states after reset.

Source: Source/Schola/Training/Public/GymConnectors/AbstractGymConnector.h

Implementation: Source/Schola/Training/Private/GymConnectors/AbstractGymConnector.cpp

ResolveEnvironmentStateUpdate

inline virtual FTrainingStateUpdate *ResolveEnvironmentStateUpdate()

Resolve the environment state update.

Useful for connections that operate off of futures, or otherwise require synchronization.

Returns:

The resolved environment state update.

Attributes: inline, virtual

Source: Source/Schola/Training/Public/GymConnectors/AbstractGymConnector.h

UpdateConnectorStatus

void UpdateConnectorStatus(const FTrainingStateUpdate &StateUpdate)

Update the connector status based on a state update.

Parameters

StateUpdate – [in] The state update to base the new status on.

#DirectionNameTypeDescription
1StateUpdateconst FTrainingStateUpdate &The state update to base the new status on.

Source: Source/Schola/Training/Public/GymConnectors/AbstractGymConnector.h

Implementation: Source/Schola/Training/Private/GymConnectors/AbstractGymConnector.cpp

CheckForStart

inline virtual bool CheckForStart()

Check if the connector is ready to start.

Returns:

True if the connector is ready to start.

Attributes: inline, virtual

Source: Source/Schola/Training/Public/GymConnectors/AbstractGymConnector.h

IsRunning

inline bool IsRunning()

Get if the connector is running.

Returns:

True if the connector is running.

Attributes: inline

Source: Source/Schola/Training/Public/GymConnectors/AbstractGymConnector.h

IsNotStarted

inline bool IsNotStarted()

Get if the connector is closed.

Returns:

True if the connector is closed.

Attributes: inline

Source: Source/Schola/Training/Public/GymConnectors/AbstractGymConnector.h

CollectEnvironments

void CollectEnvironments(
TArray<TScriptInterface<IBaseScholaEnvironment>> &OutCollectedEnvironments)

Collect all environment objects in the current world.

Searches the level for all objects implementing IBaseScholaEnvironment.

Parameters

OutCollectedEnvironments – [out] Array of found environment interfaces.

#DirectionNameTypeDescription
1OutCollectedEnvironmentsTArray< TScriptInterface< IBaseScholaEnvironment > > &Array of found environment interfaces.

Source: Source/Schola/Training/Public/GymConnectors/AbstractGymConnector.h

Implementation: Source/Schola/Training/Private/GymConnectors/AbstractGymConnector.cpp

PrepareEnvironments

void PrepareEnvironments(
const TArray<TScriptInterface<IBaseScholaEnvironment>> &InEnvironments)

Prepare environments for training by initializing and storing them.

Converts environment interfaces to the internal type-erased format.

Parameters

InEnvironments – [in] Array of environment interfaces to prepare.

#DirectionNameTypeDescription
1InEnvironmentsconst TArray< TScriptInterface< IBaseScholaEnvironment > > &Array of environment interfaces to prepare.

Source: Source/Schola/Training/Public/GymConnectors/AbstractGymConnector.h

Implementation: Source/Schola/Training/Private/GymConnectors/AbstractGymConnector.cpp

GetCompletedEnvironmentIds

void GetCompletedEnvironmentIds(const FTrainingState &InState,
TArray<int> &OutCompletedEnvironmentIds)

Get the IDs of environments that have completed their episodes.

Parameters

  • InState – [in] The training state to check for completed environments.

  • OutCompletedEnvironmentIds – [out] Array of environment IDs that are done.

#DirectionNameTypeDescription
1InStateconst FTrainingState &The training state to check for completed environments.
2OutCompletedEnvironmentIdsTArray< int > &Array of environment IDs that are done.

Source: Source/Schola/Training/Public/GymConnectors/AbstractGymConnector.h

Implementation: Source/Schola/Training/Private/GymConnectors/AbstractGymConnector.cpp

Step

void Step()

Execute one training step across all environments.

Retrieves the next action/reset update and applies it to environments. Internal state is updated in place.

Source: Source/Schola/Training/Public/GymConnectors/AbstractGymConnector.h

Implementation: Source/Schola/Training/Private/GymConnectors/AbstractGymConnector.cpp

Step

void Step(FTrainingState &OutTrainingState, FInitialState &OutInitialState)

Execute one training step and retrieve the resulting states.

Parameters

  • OutTrainingState – [out] The training state after the step.

  • OutInitialState – [out] The initial states for any reset environments.

Source: Source/Schola/Training/Public/GymConnectors/AbstractGymConnector.h

Implementation: Source/Schola/Training/Private/GymConnectors/AbstractGymConnector.cpp

GetAutoResetType

inline virtual EAutoResetType GetAutoResetType()

Get the auto-reset behavior for this connector.

Controls when environments automatically reset after episode completion.

Returns:

The auto-reset type (default: SameStep).

Attributes: inline, virtual

Source: Source/Schola/Training/Public/GymConnectors/AbstractGymConnector.h


Public Members

SymbolDetails
OnConnectorStartedDelegate broadcast when the connector starts successfully.
OnConnectorClosedDelegate broadcast when the connector closes.
OnConnectorErrorDelegate broadcast when the connector encounters an error.
EnvironmentsThe environments that are currently being used for training by this connector.
TrainingStateThe current training state containing observations, rewards, and done flags for all environments.
InitialStateThe initial state of environments at the start of the last episode.
TrainingDefinitionDefinition of the training session including environment and agent specifications.
StatusThe current operational status of the connector.
bFirstStepFlag indicating if this is the first step after initialization.

OnConnectorStarted

FConnectorStartedSignature OnConnectorStarted

Delegate broadcast when the connector starts successfully.


OnConnectorClosed

FConnectorClosedSignature OnConnectorClosed

Delegate broadcast when the connector closes.


OnConnectorError

FConnectorErrorSignature OnConnectorError

Delegate broadcast when the connector encounters an error.


Environments

TArray<IScholaEnvironment *> Environments = TArray<IScholaEnvironment *>()

The environments that are currently being used for training by this connector.


TrainingState

FTrainingState TrainingState = FTrainingState()

The current training state containing observations, rewards, and done flags for all environments.


InitialState

FInitialState InitialState = FInitialState()

The initial state of environments at the start of the last episode.


TrainingDefinition

FTrainingDefinition TrainingDefinition = FTrainingDefinition()

Definition of the training session including environment and agent specifications.


Status

EConnectorStatus Status = EConnectorStatus::Running

The current operational status of the connector.


bFirstStep

bool bFirstStep = true

Flag indicating if this is the first step after initialization.