schola.core.env.ScholaEnv

class schola.core.env.ScholaEnv(unreal_connection, verbosity=0, environment_start_timeout=45)[source]

Bases: object

A Gym-Like Environment that wraps a connection to the Unreal Engine, running the Schola Plugin for Unreal.

Parameters:
  • unreal_connection (UnrealConnection) – The connection to the Unreal Engine.

  • verbosity (int, default=0) – The verbosity level for the environment.

  • environment_start_timeout (int, default=45) – The time to wait for the environment to start in seconds.

unreal_connection

The connection to the Unreal Engine.

Type:

UnrealConnection

gym_stub

The gRPC stub for the Gym Service.

Type:

gym_grpc.GymServiceStub

ids

A nested list of all the environments and their active agents.

Type:

List[List[int]]

agent_display_names

A list of mappings from the id to the display names for each agent in each environment.

Type:

List[Dict[int,str]]

obs_defns

The observation space definitions for each agent in each environment.

Type:

Dict[int,Dict[int,DictSpace]]

action_defns

The action space definitions for each agent in each environment.

Type:

Dict[int,Dict[int,DictSpace]]

steps

The number of steps taken in the current episode of the environment.

Type:

int

next_action

The next action to be taken by each agent in each environment.

Type:

Dict[int,Dict[int,Any]], optional

Raises:
Parameters:

Methods

__init__(unreal_connection[, verbosity, …])

close()

Closes the connection to the Unreal Engine and cleans up any resources.

get_action_space(env_id, agent_id)

Get the action space for a specific environment and agent.

get_obs_space(env_id, agent_id)

Get the observation space for a specific environment and agent.

hard_reset([env_ids, seeds, options])

Perform a hard reset on the environment.

poll()

Polls the environment for the current state.

send_actions(action)

Send Actions to all agents and environments.

soft_reset([ids])

Soft reset the environment, by waiting for Unreal to rself reset and send a Post Reset State to python.

Attributes

num_agents

Return the total number of agents in the environment.

num_envs

Return the number of environments.

__init__(unreal_connection, verbosity=0, environment_start_timeout=45)[source]
Parameters:
close()[source]

Closes the connection to the Unreal Engine and cleans up any resources. It is safe to call this method multiple times.

See also

gymnasium.Env.close

The equivalent operation in gymnasium

Return type:

None

get_action_space(env_id, agent_id)[source]

Get the action space for a specific environment and agent.

Parameters:
  • env_id (int) – The ID of the environment.

  • agent_id (int) – The ID of the agent.

Returns:

The action space for the specified environment and agent.

Return type:

DictSpace

get_obs_space(env_id, agent_id)[source]

Get the observation space for a specific environment and agent.

Parameters:
  • env_id (int) – The ID of the environment.

  • agent_id (int) – The ID of the agent.

Returns:

The observation space for the specified environment and agent.

Return type:

DictSpace

hard_reset(env_ids=None, seeds=None, options=None)[source]

Perform a hard reset on the environment.

Parameters:
  • env_ids (Optional[List[int]]) – A list of environment IDs to reset. If None, all environments will be reset. Default is None.

  • seeds (Union[None, List[int], int]) – The seeds to use for random number generation. If an int is provided, it will be used as the seed for all environments. If a list of ints is provided, each environment will be assigned a seed from the list. Default is None.

  • options (Union[List[Dict[str,str]], Dict[str,str], None]) – The options to set for each environment. If a list of dictionaries is provided, each environment will be assigned the corresponding dictionary of options. If a single dictionary is provided, all environments will be assigned the same options. Default is None.

Returns:

A list of environment IDs that were reset.

Return type:

List

Raises:
  • AssertionError – If the number of seeds provided, is not zero or one, and does not match the number of environments.

  • AssertionError – If the number of options dictionaries provided, is not zero or one, does not match the number of environments.

Notes

  • If seeds are provided, the environment will be seeded with the specified values.

  • If options are provided, the environment will be configured with the specified options.

See also

gymnasium.Env.reset

The equivalent operation in gymnasium

property num_agents: int

Return the total number of agents in the environment.

Returns:

The total number of agents.

Return type:

int

property num_envs: int

Return the number of environments. :returns: The number of environments. :rtype: int

poll()[source]

Polls the environment for the current state.

Returns:
  • observations (EnvAgentIdDict[Dict[str,Any]]) – A dictionary, keyed by the environment and agent Id, containing the observations for each agent.

  • rewards (EnvAgentIdDict[float]) – A dictionary, keyed by the environment and agent Id, containing the reward for each agent.

  • terminateds (EnvAgentIdDict[bool]) – A dictionary, keyed by the environment and agent Id, containing the termination flag for each agent.

  • truncateds (EnvAgentIdDict[bool]) – A dictionary, keyed by the environment and agent Id, containing the truncation flag for each agent.

  • infos (EnvAgentIdDict[Dict[str,str]]]:) – A dictionary, keyed by the environment and agent Id, containing the information dictionary for each agent.

Return type:

Tuple[Dict[int, Dict[int, Dict[str, Any]]], Dict[int, Dict[int, float]], Dict[int, Dict[int, bool]], Dict[int, Dict[int, bool]], Dict[int, Dict[int, Dict[str, str]]]]

send_actions(action)[source]

Send Actions to all agents and environments.

Parameters:

action (EnvAgentIdDict[Dict[str,Any]]) – A dictionary, keyed by the environment and agent Id, containing the actions for all active environments and agents.

Return type:

None

Notes

The actions are not sent to Unreal until Poll is called.

See also

poll

Where the actions are actually sent to unreal

soft_reset(ids=None)[source]

Soft reset the environment, by waiting for Unreal to rself reset and send a Post Reset State to python.

Parameters:

ids (List[str], optional) – A list of environment IDs to reset. If not provided or set to None, all environment IDs will be reset.

Returns:
  • observations (EnvAgentIdDict[Dict[str,Any]]) – A dictionary, keyed by the environment and agent Id, containing the observations of the agents in the environments immediately following a reset

  • infos (EnvAgentIdDict[Dict[str,str]]) – A dictionary, keyed by the environment and agent Id, containing the infos of the agents in the environment

Return type:

Tuple[Dict[int, Dict[int, Dict[str, Any]]], Dict[int, Dict[int, Dict[str, str]]]]

Related pages

  • Visit the Schola product page for download links and more information.

Looking for more documentation on GPUOpen?

AMD GPUOpen software blogs

Our handy software release blogs will help you make good use of our tools, SDKs, and effects, as well as sharing the latest features with new releases.

GPUOpen Manuals

Don’t miss our manual documentation! And if slide decks are what you’re after, you’ll find 100+ of our finest presentations here.

AMD GPUOpen Performance Guides

The home of great performance and optimization advice for AMD RDNA™ 2 GPUs, AMD Ryzen™ CPUs, and so much more.

Getting started: AMD GPUOpen software

New or fairly new to AMD’s tools, libraries, and effects? This is the best place to get started on GPUOpen!

AMD GPUOpen Getting Started Development and Performance

Looking for tips on getting started with developing and/or optimizing your game, whether on AMD hardware or generally? We’ve got you covered!

AMD GPUOpen Technical blogs

Browse our technical blogs, and find valuable advice on developing with AMD hardware, ray tracing, Vulkan®, DirectX®, Unreal Engine, and lots more.

Find out more about our software!

AMD GPUOpen Effects - AMD FidelityFX technologies

Create wonder. No black boxes. Meet the AMD FidelityFX SDK!

AMD GPUOpen Samples

Browse all our useful samples. Perfect for when you’re needing to get started, want to integrate one of our libraries, and much more.

AMD GPUOpen developer SDKs

Discover what our SDK technologies can offer you. Query hardware or software, manage memory, create rendering applications or machine learning, and much more!

AMD GPUOpen Developer Tools

Analyze, Optimize, Profile, Benchmark. We provide you with the developer tools you need to make sure your game is the best it can be!