unreal.LearningAgentsInteractor

class unreal.LearningAgentsInteractor(outer: Object | None = None, name: Name | str = 'None')

Bases: LearningAgentsManagerListener

ULearningAgentsInteractor defines how agents interact with the environment through their observations and actions.

To use this class, you need to implement SpecifyAgentObservation and SpecifyAgentAction, which will define the structure of inputs and outputs to your policy. You also need to implement GatherAgentObservation and PerformAgentAction which will dictate how those observations are gathered, and actions actuated in your environment.

C++ Source:

  • Plugin: LearningAgents

  • Module: LearningAgents

  • File: LearningAgentsInteractor.h

Editor Properties: (see get_editor_property/set_editor_property)

  • action_object (LearningAgentsActionObject): [Read-Only] Action Object used by this interactor

  • action_object_elements (Array[LearningAgentsActionObjectElement]): [Read-Only] Action Object Elements used by this interactor

  • action_schema (LearningAgentsActionSchema): [Read-Only] Action Schema used by this interactor

  • action_schema_element (LearningAgentsActionSchemaElement): [Read-Only] Action Schema Element used by this interactor

  • is_setup (bool): [Read-Only] True if this object has been setup. Otherwise, false.

  • manager (LearningAgentsManager): [Read-Only] The manager this object is associated with.

  • observation_object (LearningAgentsObservationObject): [Read-Only] Observation Object used by this interactor

  • observation_object_elements (Array[LearningAgentsObservationObjectElement]): [Read-Only] Observation Object Elements used by this interactor

  • observation_schema (LearningAgentsObservationSchema): [Read-Only] Observation Schema used by this interactor

  • observation_schema_element (LearningAgentsObservationSchemaElement): [Read-Only] Observation Schema Element used by this interactor

  • visual_logger_objects (Map[Name, LearningAgentsVisualLoggerObject]): [Read-Only] The visual logger objects associated with this listener.

gather_agent_observation(observation_object, agent_id) LearningAgentsObservationObjectElement

This callback should be overridden by the Interactor and gathers the observations for a single agent. The structure of the Observation Elements output by this function should match that defined by the Schema.

Parameters:
Returns:

out_observation_object_element (LearningAgentsObservationObjectElement): Output Observation Element.

Return type:

LearningAgentsObservationObjectElement

gather_agent_observations(observation_object, agent_ids) Array[LearningAgentsObservationObjectElement]

This callback can be overridden by the Interactor and gathers all the observations for the given agents. The structure of the Observation Elements output by this function should match that defined by the Schema. The default implementation calls GatherAgentObservation on each agent.

Parameters:
Returns:

out_observation_object_elements (Array[LearningAgentsObservationObjectElement]): Output Observation Elements. This should be the same size as AgentIds.

Return type:

Array[LearningAgentsObservationObjectElement]

gather_observations() None

Gathers all the observations for all agents. This will call GatherAgentObservations.

get_action_distribution_vector_size() int32

Gets the size of the action distribution vector used by this interactor.

Return type:

int32

get_action_encoded_vector_size() int32

Gets the size of the encoded action vector used by this interactor.

Return type:

int32

get_action_vector(agent_id=-1) -> (out_action_vector=Array[float], out_action_compatibility_hash=int32)

Get the current buffered action vector for the given agent.

Parameters:

agent_id (int32) – Agent Id to look up the action vector for.

Returns:

out_action_vector (Array[float]): Output Action Vector

out_action_compatibility_hash (int32): Output Compatibility Hash used to identify which schema this vector is compatible with.

Return type:

tuple

get_action_vector_size() int32

Gets the size of the action vector used by this interactor.

Return type:

int32

get_observation_encoded_vector_size() int32

Gets the size of the encoded observation vector used by this interactor.

Return type:

int32

get_observation_vector(agent_id=-1) -> (out_observation_vector=Array[float], out_observation_compatibility_hash=int32)

Get the current buffered observation vector for the given agent.

Parameters:

agent_id (int32) – Agent Id to look up the observation vector for.

Returns:

out_observation_vector (Array[float]): Output Observation Vector

out_observation_compatibility_hash (int32): Output Compatibility Hash used to identify which schema this vector is compatible with.

Return type:

tuple

get_observation_vector_size() int32

Gets the size of the observation vector used by this interactor.

Return type:

int32

has_action_vector(agent_id=-1) bool

Returns true if DecodeAndSampleActions on the policy or SetActionVector has been called and the action vector already set for the given agent.

Parameters:

agent_id (int32) –

Return type:

bool

has_observation_vector(agent_id=-1) bool

Returns true if GatherObservations or SetObservationVector has been called and the observation vector already set for the given agent.

Parameters:

agent_id (int32) –

Return type:

bool

classmethod make_interactor(manager, class_, name='Interactor') LearningAgentsInteractor

Constructs an Interactor.

Parameters:
Return type:

LearningAgentsInteractor

perform_actions() None

Performs all the actions for all agents. This will call PerformAgentActions.

perform_agent_action(action_object, action_object_element, agent_id) None

This callback should be overridden by the Interactor and performs the action for the given agent in the world. The structure of the Action Elements given as input to this function will match that defined by the Schema.

Parameters:
perform_agent_actions(action_object, action_object_elements, agent_ids) None

This callback can be overridden by the Interactor and performs all the actions for the given agents in the world. The structure of the Action Elements given as input to this function will match that defined by the Schema. The default implementation calls PerformAgentAction on each agent.

Parameters:
set_action_vector(action_vector, action_compatibility_hash, agent_id=-1, increment_iteration=True) None

Sets the current buffered action vector for the given agent.

Parameters:
  • action_vector (Array[float]) – Action Vector

  • action_compatibility_hash (int32) – Compatibility Hash used to identify which schema this vector is compatible with.

  • agent_id (int32) – Agent Id to set the observation vector for.

  • increment_iteration (bool) – If to increment the iteration number used to keep track of associated actions and observations.

set_observation_vector(observation_vector, observation_compatibility_hash, agent_id=-1, increment_iteration=True) None

Sets the current buffered observation vector for the given agent.

Parameters:
  • observation_vector (Array[float]) – Observation Vector

  • observation_compatibility_hash (int32) – Compatibility Hash used to identify which schema this vector is compatible with.

  • agent_id (int32) – Agent Id to set the observation vector for.

  • increment_iteration (bool) – If to increment the iteration number used to keep track of associated actions and observations.

setup_interactor(manager) None

Initializes an Interactor.

Parameters:

manager (LearningAgentsManager) – The input Manager

specify_agent_action(action_schema) LearningAgentsActionSchemaElement

This callback should be overridden by the Interactor and specifies the structure of the actions using the Action Schema.

Parameters:

action_schema (LearningAgentsActionSchema) – Action Schema

Returns:

out_action_schema_element (LearningAgentsActionSchemaElement): Output Schema Element

Return type:

LearningAgentsActionSchemaElement

specify_agent_observation(observation_schema) LearningAgentsObservationSchemaElement

This callback should be overridden by the Interactor and specifies the structure of the observations using the Observation Schema.

Parameters:

observation_schema (LearningAgentsObservationSchema) – Observation Schema

Returns:

out_observation_schema_element (LearningAgentsObservationSchemaElement): Output Schema Element

Return type:

LearningAgentsObservationSchemaElement