unreal.LearningAgentsManager

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

Bases: ActorComponent

The agent manager is responsible for tracking which game objects are agents. It’s the central class around which most of Learning Agents is built.

If you have multiple different types of objects you want controlled by Learning Agents, you should consider creating one agent manager per object type, rather than trying to share an agent manager.

C++ Source:

  • Plugin: LearningAgents

  • Module: LearningAgents

  • File: LearningAgentsManager.h

Editor Properties: (see get_editor_property/set_editor_property)

  • agents (Array[Object]): [Read-Only] The list of current agents.

  • asset_user_data (Array[AssetUserData]): [Read-Write] Array of user data stored with the component

  • asset_user_data_editor_only (Array[AssetUserData]): [Read-Write] Array of user data stored with the component

  • auto_activate (bool): [Read-Write] Whether the component is activated at creation or must be explicitly activated.

  • can_ever_affect_navigation (bool): [Read-Write] Whether this component can potentially influence navigation

  • component_tags (Array[Name]): [Read-Write] Array of tags that can be used for grouping and categorizing. Can also be accessed from scripting.

  • editable_when_inherited (bool): [Read-Write] True if this component can be modified when it was inherited from a parent actor class

  • is_editor_only (bool): [Read-Write] If true, the component will be excluded from non-editor builds

  • listeners (Array[LearningAgentsManagerListener]): [Read-Only] The list of current listeners.

  • max_agent_num (int32): [Read-Write] Maximum number of agents. Used to preallocate internal buffers. Setting this higher will allow more agents but use up more memory.

  • on_component_activated (ActorComponentActivatedSignature): [Read-Write] Called when the component has been activated, with parameter indicating if it was from a reset

  • on_component_deactivated (ActorComponentDeactivateSignature): [Read-Write] Called when the component has been deactivated

  • primary_component_tick (ActorComponentTickFunction): [Read-Write] Main tick function for the Component

  • replicate_using_registered_sub_object_list (bool): [Read-Write] When true the replication system will only replicate the registered subobjects list When false the replication system will instead call the virtual ReplicateSubObjects() function where the subobjects need to be manually replicated.

  • replicates (bool): [Read-Write] Is this component currently replicating? Should the network code consider it for replication? Owning Actor must be replicating first!

add_agent(agent) int32

Adds the given object as an agent to the manager.

Parameters:

agent (Object) – The object to be added.

Returns:

The agent’s newly assigned id.

Return type:

int32

add_agents(agents) Array[int32]

Adds the given objects as an agents to the manager.

Parameters:

agents (Array[Object]) – The objects to be added.

Returns:

out_agent_ids (Array[int32]): The output newly assigned agent ids

Return type:

Array[int32]

add_listener(listener) None

Adds a listener to be tracked by this manager.

Parameters:

listener (LearningAgentsManagerListener) –

get_agent(agent_id=-1, agent_class) Object

Gets the agent with the given id. Calling this from blueprint with the appropriate AgentClass will automatically cast the object to the given type. If not in a blueprint, you should use one of the other GetAgent overloads.

Parameters:
  • agent_id (int32) – The id of the agent to get.

  • agent_class (type(Class)) – The class to cast the agent object to (in blueprint).

Returns:

The agent object.

Return type:

Object

get_agent_id(agent) int32

Gets the agent id associated with a given agent.

Parameters:

agent (Object) – The agent object.

Returns:

The agent id.

Return type:

int32

get_agent_ids(agents) Array[int32]

Gets the agent ids associated with a set of agents.

Parameters:

agents (Array[Object]) – The agent objects.

Returns:

out_agent_ids (Array[int32]): The ids of the agents.

Return type:

Array[int32]

get_agent_num() int32

Gets the number of agents added

Returns:

The number of agents added.

Return type:

int32

get_agents(agent_ids, agent_class) Array[Object]

Gets the agents associated with a set of ids. Calling this from blueprint with the appropriate AgentClass will automatically cast the object to the given type.

Parameters:
  • agent_ids (Array[int32]) – The ids of the agents to get.

  • agent_class (type(Class)) – The class to cast the agent objects to (in blueprint).

Returns:

out_agents (Array[Object]): The output array of agent objects.

Return type:

Array[Object]

get_all_agents(agent_class) -> (out_agents=Array[Object], out_agent_ids=Array[int32])

Gets all added agents. Calling this from blueprint with the appropriate AgentClass will automatically cast the object to the given type.

Parameters:

agent_class (type(Class)) – The class to cast the agent objects to (in blueprint).

Returns:

out_agents (Array[Object]): The output array of agent objects.

out_agent_ids (Array[int32]): The output array of agent ids.

Return type:

tuple

get_max_agent_num() int32

Returns the maximum number of agents that this manager is configured to handle.

Return type:

int32

has_agent(agent_id=-1) bool

Returns true if the given id is an agent used by the manager; Otherwise, false.

Parameters:

agent_id (int32) –

Return type:

bool

has_agent_object(agent) bool

Returns true if the given object is an agent used by the manager; Otherwise, false.

Parameters:

agent (Object) –

Return type:

bool

remove_agent(agent_id=-1) None

Removes the agent with the given id from the manager.

Parameters:

agent_id (int32) – The id of the agent to remove.

remove_agents(agent_ids) None

Removes the agents with the given ids from the manager.

Parameters:

agent_ids (Array[int32]) – The ids of the agents to remove.

remove_all_agents() None

Removes all agents from the manager.

remove_listener(listener) None

Removes a listener from being tracked by this manager.

Parameters:

listener (LearningAgentsManagerListener) –

reset_agent(agent_id=-1) None

Resets the agent with the given id on the manager. Used to tell components to reset any state associated with this agent.

Parameters:

agent_id (int32) – The id of the agent to reset.

reset_agents(agent_ids) None

Resets the agents with the given ids on the manager. Used to tell components to reset any state associated with this agent.

Parameters:

agent_ids (Array[int32]) – The ids of the agents to reset.

reset_all_agents() None

Resets all the agents on the manager.