Skip to content

schola.ray.env.BaseEnv

Class Definition

class schola.ray.env.BaseEnv(
unreal_connection,
verbosity=0
)

Bases: BaseEnv

A Ray RLlib environment that wraps a Schola environment.

Parameters

unreal_connection

Type: UnrealConnection
The connection to the Unreal Engine environment.

verbosity

Type: int
Default: 0
The verbosity level for the environment.

Attributes

unwrapped

Type: MultiAgentEnv
The underlying multi-agent environment.

last_reset_obs

Type: Dict[int, Dict[str, Any]]
The observations recorded during the last reset.

last_reset_infos

Type: Dict[int, Dict[str, str]]
The info dict recorded during the last reset.

Properties

action_space

Type: DictSpace (property)
The action space for the environment.

Returns: The action space for the environment

Return type: DictSpace

num_envs

Type: int (property)
The number of sub-environments in the wrapped environment.

Returns: The number of sub-environments in the wrapped environment.

Return type: int

observation_space

Type: DictSpace (property)
The observation space for the environment.

Returns: The observation space for the environment.

Return type: DictSpace

Methods

__init__

__init__(unreal_connection, verbosity=0)

Parameters:

get_agent_ids

get_agent_ids()

Return the agent ids for the sub_environment.

get_sub_environments

get_sub_environments(as_dict=False)

Return a reference to the underlying sub environments, if any.

last

last()

Returns the last observations, rewards, done- truncated flags and infos …

poll

poll()

Poll the environment for the next observation, reward, termination, info and any off_policy_actions (Currently Unused).

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.
  • off_policy_actions (EnvAgentIdDict[Any]) – A dictionary, keyed by the environment and agent Id, containing the off-policy actions for each agent. Unused.

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]]], Dict[int, Dict[int, Any]]]

send_actions

send_actions(action_dict)

Called to send actions back to running agents in this env. Actions should be sent for each ready agent that returned observations in the previous poll() call.

Parameters:

  • action_dict (Dict[int, Dict[int, Dict[str, Any]]]) – Actions values keyed by env_id and agent_id.

Return type: None

stop

stop()

Releases all resources used.

Return type: None

to_base_env

to_base_env(make_env=None, num_envs=1, remote_envs=False, remote_env_batch_wait_ms=0)

Converts an RLlib-supported env into a BaseEnv object.

try_render

try_render(env_id=None)

Tries to render the sub-environment with the given id or all.

try_reset

try_reset(env_id=None, seed=None, options=None)

Attempt to reset the sub-env with the given id or all sub-envs. If the environment does not support synchronous reset, a tuple of (ASYNC_RESET_REQUEST, ASYNC_RESET_REQUEST) can be returned here.

Note: A MultiAgentDict is returned when using the deprecated wrapper classes such as ray.rllib.env.base_env._MultiAgentEnvToBaseEnv, however for consistency with the poll() method, a MultiEnvDict is returned from the new wrapper classes, such as ray.rllib.env.multi_agent_env.MultiAgentEnvWrapper.

Parameters:

  • env_id (int | None) – The sub-environment’s ID if applicable. If None, reset the entire Env (i.e. all sub-environments).
  • seed (None | List[int] | int) – The seed to be passed to the sub-environment(s) when resetting it. If None, will not reset any existing PRNG. If you pass an integer, the PRNG will be reset even if it already exists.
  • options (Dict[str, str] | None) – An options dict to be passed to the sub-environment(s) when resetting it.

Returns: A tuple consisting of a) the reset (multi-env/multi-agent) observation dict and b) the reset (multi-env/multi-agent) infos dict. Returns the (ASYNC_RESET_REQUEST, ASYNC_RESET_REQUEST) tuple, if not supported.

try_restart

try_restart(env_id=None)

Attempt to restart the sub-env with the given id or all sub-envs.