unreal.LearningAgentsTrainingEnvironment

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

Bases: LearningAgentsManagerListener

Learning Agents Training Environment

C++ Source:

  • Plugin: LearningAgents

  • Module: LearningAgentsTraining

  • File: LearningAgentsTrainingEnvironment.h

Editor Properties: (see get_editor_property/set_editor_property)

  • 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.

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

gather_agent_completion(agent_id) LearningAgentsCompletionEnum

This callback should be overridden by the Trainer and gathers the completion for a given agent.

Parameters:

agent_id (int32) – Agent id to gather completion for.

Returns:

out_completion (LearningAgentsCompletionEnum): Output completion for the given agent.

Return type:

LearningAgentsCompletionEnum

gather_agent_completions(agent_ids) Array[LearningAgentsCompletionEnum]

This callback can be overridden by the Trainer and gathers all the completions for the given set of agents. By default this will call GatherAgentCompletion on each agent.

Parameters:

agent_ids (Array[int32]) – Agents to gather completions for.

Returns:

out_completions (Array[LearningAgentsCompletionEnum]): Output completions for each agent in AgentIds

Return type:

Array[LearningAgentsCompletionEnum]

gather_agent_reward(agent_id) float

This callback should be overridden by the Trainer and gathers the reward value for the given agent.

Parameters:

agent_id (int32) – Agent id to gather reward for.

Returns:

out_reward (float): Output reward for the given agent.

Return type:

float

gather_agent_rewards(agent_ids) Array[float]

This callback can be overridden by the Trainer and gathers all the reward values for the given set of agents. By default this will call GatherAgentReward on each agent.

Parameters:

agent_ids (Array[int32]) – Agents to gather rewards for.

Returns:

out_rewards (Array[float]): Output rewards for each agent in AgentIds

Return type:

Array[float]

gather_completions() None

Call this function when it is time to evaluate the completions for your agents. This should be done at the beginning of each iteration of your training loop after the initial step, i.e. after taking an action, you want to get into the next state before evaluating the completions.

gather_rewards() None

Call this function when it is time to evaluate the rewards for your agents. This should be done at the beginning of each iteration of your training loop after the initial step, i.e. after taking an action, you want to get into the next state before evaluating the rewards.

get_completion(agent_id=-1) LearningAgentsCompletionEnum

Gets the current completion for an agent. Should be called only after GatherCompletions.

Parameters:

agent_id (int32) – The AgentId to look-up the completion for

Returns:

The completion type

Return type:

LearningAgentsCompletionEnum

get_episode_time(agent_id=-1) float

Gets the current elapsed episode time for the given agent.

Parameters:

agent_id (int32) – The AgentId to look-up the episode time for

Returns:

The elapsed episode time

Return type:

float

get_reward(agent_id=-1) float

Gets the current reward for an agent. Should be called only after GatherRewards.

Parameters:

agent_id (int32) – The AgentId to look-up the reward for

Returns:

The reward

Return type:

float

has_completion(agent_id=-1) bool

Returns true if GatherCompletions has been called and the completion already set for the given agent.

Parameters:

agent_id (int32)

Return type:

bool

has_reward(agent_id=-1) bool

Returns true if GatherRewards has been called and the reward already set for the given agent.

Parameters:

agent_id (int32)

Return type:

bool

classmethod make_training_environment(manager, class_, name="TrainingEnvironment") -> (LearningAgentsTrainingEnvironment, manager=LearningAgentsManager)

Constructs the training environment and runs the setup functions for rewards and completions.

Parameters:
Returns:

manager (LearningAgentsManager):

Return type:

LearningAgentsManager

reset_agent_episode(agent_id) None

This callback should be overridden by the Trainer and resets the episode for the given agent.

Parameters:

agent_id (int32) – The id of the agent that need resetting.

reset_agent_episodes(agent_ids) None

This callback can be overridden by the Trainer and resets all episodes for each agent in the given set. By default this will call ResetAgentEpisode on each agent.

Parameters:

agent_ids (Array[int32]) – The ids of the agents that need resetting.

setup_training_environment(manager) LearningAgentsManager

Initializes the training environment and runs the setup functions for rewards and completions.

Parameters:

manager (LearningAgentsManager)

Returns:

manager (LearningAgentsManager):

Return type:

LearningAgentsManager