schola.gym.env.GymVectorEnv
- class schola.gym.env.GymVectorEnv(unreal_connection, verbosity=0)[source]
-
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.
-
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.
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)[source]
-
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)[source]
- close()[source]
-
Close all parallel environments and release resources.
It also closes all the existing image viewers, then calls
close_extras()
and setclosed
asTrue
.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)[source]
-
Get an attribute from the environment.
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)[source]
-
Reset the sub-environments asynchronously.
This method will return
None
. A call toreset_async()
should be followed by a call toreset_wait()
to retrieve the results.- Parameters:
-
-
seed – The reset seed
-
options – Reset options
-
- reset_wait(seed=None, options=None)[source]
-
Retrieves the results of a
reset_async()
call.A call to this method must always be preceded by a call to
reset_async()
.- Parameters:
- Returns:
-
The results from
reset_async()
- Raises:
-
NotImplementedError – VectorEnv does not implement function
- Return type:
- step_async(actions)[source]
-
Asynchronously performs steps in the sub-environments.
The results can be retrieved via a call to
step_wait()
.
- step_wait()[source]
-
Retrieves the results of a
step_async()
call.A call to this method must always be preceded by a call to
step_async()
.
- unbatch_actions(actions)[source]
-
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.