schola.gym.env.GymVectorEnv
class schola.gym.env.GymVectorEnv(unreal_connection, verbosity=0)
: Bases: VectorEnv
A Gym Vector Environment that wraps a Schola Environment.
Parameters: : - unreal_connection (UnrealConnection) – The connection to the Unreal Engine.
- verbosity (int, default=0) – The verbosity level for the environment.
reset_infos : The information returned from the last reset.
Methods
__init__ (unreal_connection[, verbosity]) | Base class for vectorized environments. |
batch_obs (obs) | |
call (name, *args, **kwargs) | Call a method, or get a property, from each parallel environment. |
call_async (name, *args, **kwargs) | Calls a method name for each parallel environment asynchronously. |
call_wait (**kwargs) | After calling a method in call_async() , this function collects the results. |
close () | Close all parallel environments and release resources. |
close_extras (**kwargs) | Clean up the extra resources e.g. beyond what’s in this base class. |
get_attr (name) | Get an attribute from the environment. |
get_wrapper_attr (name) | Gets the attribute name from the environment. |
render () | Compute the render frames as specified by render_mode during the initialization of the environment. |
reset (*[, seed, options]) | Reset all parallel environments and return a batch of initial observations and info. |
reset_async ([seed, options]) | Reset the sub-environments asynchronously. |
reset_wait ([seed, options]) | Retrieves the results of a reset_async() call. |
set_attr (name, values) | Set a property in each sub-environment. |
step (actions) | Take an action for each parallel environment. |
step_async (actions) | Asynchronously performs steps in the sub-environments. |
step_wait () | Retrieves the results of a step_async() call. |
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. |
Attributes
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 |
__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(obs) : Parameters: : obs (Dict[int, Dict[int, Dict[str, ndarray*]]]*)
Return type: : Dict[str, ndarray]
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
.
Warning
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.
Note
This will be automatically called when garbage collected or program exited.
Parameters:
: **kwargs – Keyword arguments passed to close_extras()
Return type: : None
get_attr(name) : Get an attribute from the environment.
Parameters: : name (str) – The name of the attribute to get.
Return type: : List[None]
Notes
This method is not implemented and will always return a list of None values, as sub-environments are not individually accessible.
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(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
Returns:
: The results from reset_async()
Raises: : NotImplementedError – VectorEnv does not implement function
Return type: : Tuple[Dict[str, ndarray], Dict[int, Dict[str, str]]]
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()
: 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(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.