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 interactoraction_object_elements
(Array[LearningAgentsActionObjectElement]): [Read-Only] Action Object Elements used by this interactoraction_schema
(LearningAgentsActionSchema): [Read-Only] Action Schema used by this interactoraction_schema_element
(LearningAgentsActionSchemaElement): [Read-Only] Action Schema Element used by this interactoris_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 interactorobservation_object_elements
(Array[LearningAgentsObservationObjectElement]): [Read-Only] Observation Object Elements used by this interactorobservation_schema
(LearningAgentsObservationSchema): [Read-Only] Observation Schema used by this interactorobservation_schema_element
(LearningAgentsObservationSchemaElement): [Read-Only] Observation Schema Element used by this interactorvisual_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:
observation_object (LearningAgentsObservationObject) – Observation Object.
agent_id (int32) – The Agent Id to gather observations for.
- Returns:
out_observation_object_element (LearningAgentsObservationObjectElement): Output Observation Element.
- Return type:
- 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:
observation_object (LearningAgentsObservationObject) – Observation Object.
agent_ids (Array[int32]) – Set of Agent Ids to gather observations for.
- Returns:
out_observation_object_elements (Array[LearningAgentsObservationObjectElement]): Output Observation Elements. This should be the same size as AgentIds.
- Return type:
- 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:
- 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:
- classmethod make_interactor(manager, class_, name='Interactor') LearningAgentsInteractor ¶
Constructs an Interactor.
- Parameters:
manager (LearningAgentsManager) – The input Manager
name (Name) – The interactor name
- Return type:
- 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:
action_object (LearningAgentsActionObject) – Action Object.
action_object_element (LearningAgentsActionObjectElement) – Input Actions Element.
agent_id (int32) – Agent Id to perform actions for.
- 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:
action_object (LearningAgentsActionObject) – Action Object.
action_object_elements (Array[LearningAgentsActionObjectElement]) – Input Actions Element. This will be the same size as AgentIds.
agent_ids (Array[int32]) – Set of Agent Ids to perform actions for.
- 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_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_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:
- 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: