Team Ai
Modelpublic

AnnaMats/ppo-Pyramids-Training

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes110downloads
Python-Gym-API-Documentation.md162 linesDownload Raw Back to docs
1# Table of Contents2 3* [mlagents\_envs.envs.unity\_gym\_env](#mlagents_envs.envs.unity_gym_env)4  * [UnityGymException](#mlagents_envs.envs.unity_gym_env.UnityGymException)5  * [UnityToGymWrapper](#mlagents_envs.envs.unity_gym_env.UnityToGymWrapper)6    * [\_\_init\_\_](#mlagents_envs.envs.unity_gym_env.UnityToGymWrapper.__init__)7    * [reset](#mlagents_envs.envs.unity_gym_env.UnityToGymWrapper.reset)8    * [step](#mlagents_envs.envs.unity_gym_env.UnityToGymWrapper.step)9    * [render](#mlagents_envs.envs.unity_gym_env.UnityToGymWrapper.render)10    * [close](#mlagents_envs.envs.unity_gym_env.UnityToGymWrapper.close)11    * [seed](#mlagents_envs.envs.unity_gym_env.UnityToGymWrapper.seed)12  * [ActionFlattener](#mlagents_envs.envs.unity_gym_env.ActionFlattener)13    * [\_\_init\_\_](#mlagents_envs.envs.unity_gym_env.ActionFlattener.__init__)14    * [lookup\_action](#mlagents_envs.envs.unity_gym_env.ActionFlattener.lookup_action)15 16<a name="mlagents_envs.envs.unity_gym_env"></a>17# mlagents\_envs.envs.unity\_gym\_env18 19<a name="mlagents_envs.envs.unity_gym_env.UnityGymException"></a>20## UnityGymException Objects21 22```python23class UnityGymException(error.Error)24```25 26Any error related to the gym wrapper of ml-agents.27 28<a name="mlagents_envs.envs.unity_gym_env.UnityToGymWrapper"></a>29## UnityToGymWrapper Objects30 31```python32class UnityToGymWrapper(gym.Env)33```34 35Provides Gym wrapper for Unity Learning Environments.36 37<a name="mlagents_envs.envs.unity_gym_env.UnityToGymWrapper.__init__"></a>38#### \_\_init\_\_39 40```python41 | __init__(unity_env: BaseEnv, uint8_visual: bool = False, flatten_branched: bool = False, allow_multiple_obs: bool = False, action_space_seed: Optional[int] = None)42```43 44Environment initialization45 46**Arguments**:47 48- `unity_env`: The Unity BaseEnv to be wrapped in the gym. Will be closed when the UnityToGymWrapper closes.49- `uint8_visual`: Return visual observations as uint8 (0-255) matrices instead of float (0.0-1.0).50- `flatten_branched`: If True, turn branched discrete action spaces into a Discrete space rather than51    MultiDiscrete.52- `allow_multiple_obs`: If True, return a list of np.ndarrays as observations with the first elements53    containing the visual observations and the last element containing the array of vector observations.54    If False, returns a single np.ndarray containing either only a single visual observation or the array of55    vector observations.56- `action_space_seed`: If non-None, will be used to set the random seed on created gym.Space instances.57 58<a name="mlagents_envs.envs.unity_gym_env.UnityToGymWrapper.reset"></a>59#### reset60 61```python62 | reset() -> Union[List[np.ndarray], np.ndarray]63```64 65Resets the state of the environment and returns an initial observation.66Returns: observation (object/list): the initial observation of the67space.68 69<a name="mlagents_envs.envs.unity_gym_env.UnityToGymWrapper.step"></a>70#### step71 72```python73 | step(action: List[Any]) -> GymStepResult74```75 76Run one timestep of the environment's dynamics. When end of77episode is reached, you are responsible for calling `reset()`78to reset this environment's state.79Accepts an action and returns a tuple (observation, reward, done, info).80 81**Arguments**:82 83- `action` _object/list_ - an action provided by the environment84 85**Returns**:86 87- `observation` _object/list_ - agent's observation of the current environment88  reward (float/list) : amount of reward returned after previous action89- `done` _boolean/list_ - whether the episode has ended.90- `info` _dict_ - contains auxiliary diagnostic information.91 92<a name="mlagents_envs.envs.unity_gym_env.UnityToGymWrapper.render"></a>93#### render94 95```python96 | render(mode="rgb_array")97```98 99Return the latest visual observations.100Note that it will not render a new frame of the environment.101 102<a name="mlagents_envs.envs.unity_gym_env.UnityToGymWrapper.close"></a>103#### close104 105```python106 | close() -> None107```108 109Override _close in your subclass to perform any necessary cleanup.110Environments will automatically close() themselves when111garbage collected or when the program exits.112 113<a name="mlagents_envs.envs.unity_gym_env.UnityToGymWrapper.seed"></a>114#### seed115 116```python117 | seed(seed: Any = None) -> None118```119 120Sets the seed for this env's random number generator(s).121Currently not implemented.122 123<a name="mlagents_envs.envs.unity_gym_env.ActionFlattener"></a>124## ActionFlattener Objects125 126```python127class ActionFlattener()128```129 130Flattens branched discrete action spaces into single-branch discrete action spaces.131 132<a name="mlagents_envs.envs.unity_gym_env.ActionFlattener.__init__"></a>133#### \_\_init\_\_134 135```python136 | __init__(branched_action_space)137```138 139Initialize the flattener.140 141**Arguments**:142 143- `branched_action_space`: A List containing the sizes of each branch of the action144space, e.g. [2,3,3] for three branches with size 2, 3, and 3 respectively.145 146<a name="mlagents_envs.envs.unity_gym_env.ActionFlattener.lookup_action"></a>147#### lookup\_action148 149```python150 | lookup_action(action)151```152 153Convert a scalar discrete action into a unique set of branched actions.154 155**Arguments**:156 157- `action`: A scalar value representing one of the discrete actions.158 159**Returns**:160 161The List containing the branched actions.162