schola.gym.env.GymVectorEnv
Class Definition
class schola.gym.env.GymVectorEnv( unreal_connection, verbosity=0)Bases: VectorEnv
A Gym Vector Environment that wraps a Schola Environment.
Parameters
unreal_connection
Type: UnrealConnection
The connection to the Unreal Engine.
verbosity
Type: int
Default: 0
The verbosity level for the environment.
Attributes
reset_infos
Type: List[Dict[str, str]]
The information returned from the last reset.
metadata
np_random
Returns the environment’s internal_np_random that if not set will initialise with a random seed.
render_mode
reward_range
spec
unwrapped
Returns the base non-wrapped environment.
action_space
observation_space
Methods
__init__
__init__(unreal_connection, verbosity=0)Base class for vectorized environments.
Parameters:
- num_envs – Number of environments in the vectorized environment
- observation_space – Observation space of a single environment
- action_space – Action space of a single environment
- unreal_connection (
UnrealConnection) - verbosity (
int)
batch_obs
batch_obs(obs)Parameters:
- obs (
Dict[int, Dict[int, Dict[str, ndarray]]])
Return type: Dict[str, ndarray]
call
call(name, *args, **kwargs)Call a method, or get a property, from each parallel environment.
call_async
call_async(name, *args, **kwargs)Calls a method name for each parallel environment asynchronously.
call_wait
call_wait(**kwargs)After calling a method in call_async(), this function collects the results.
close
close()Close all parallel environments and release resources. It also closes all the existing image viewers, then calls close_extras() and set closed as True.
This function itself does not close the environments, it should be handled in close_extras(). This is generic for both synchronous and asynchronous vectorized environments.
Parameters:
- **kwargs – Keyword arguments passed to
close_extras()
Return type: None
close_extras
close_extras(**kwargs)Clean up the extra resources e.g. beyond what’s in this base class.
get_attr
get_attr(name)Get an attribute from the environment.
Parameters:
- name (
str) – The name of the attribute to get
Return type: List[None]
get_wrapper_attr
get_wrapper_attr(name)Gets the attribute name from the environment.
render
render()Compute the render frames as specified by render_mode during the initialization of the environment.
reset
reset(*, seed=None, options=None)Reset all parallel environments and return a batch of initial observations and info.
reset_async
reset_async(seed=None, options=None)Reset the sub-environments asynchronously. This method will return None. A call to reset_async() should be followed by a call to reset_wait() to retrieve the results.
Parameters:
- seed – The reset seed
- options – Reset options
reset_wait
reset_wait(seed=None, options=None)Retrieves the results of a reset_async() call. A call to this method must always be preceded by a call to reset_async().
Parameters:
- seed (
None | List[int] | int) – The reset seed - options (
List[Dict[str, str]] | Dict[str, str] | None) – Reset options
Returns: The results from reset_async()
Raises: NotImplementedError – VectorEnv does not implement function
Return type: Tuple[Dict[str, ndarray], Dict[int, Dict[str, str]]]
set_attr
set_attr(name, values)Set a property in each sub-environment.
step
step(actions)Take an action for each parallel environment.
step_async
step_async(actions)Asynchronously performs steps in the sub-environments. The results can be retrieved via a call to step_wait().
Parameters:
- actions (
Dict[int, ndarray]) – The actions to take asynchronously
Return type: None
step_wait
step_wait()Retrieves the results of a step_async() call. A call to this method must always be preceded by a call to step_async().
Parameters:
- **kwargs – Additional keywords for vector implementation
Returns: The results from the step_async() call
Return type: Tuple[Dict[str, ndarray], ndarray, ndarray, ndarray, Dict[int, Dict[str, str]]]
unbatch_actions
unbatch_actions(actions)Unbatch actions from Dict[ObsID,Batched] to a nested Dict[EnvId,Dict[AgentId,Dict[ObsId,Value]]], effectively moving the env, and agent dimensions into Dictionaries.
Parameters:
- actions (
Dict[int, np.ndarray]) – The batched actions to unbatch
Returns: The unbatched actions
Return type: Dict[int, Dict[int, Dict[str, np.ndarray]]]