|
| 1 | +# Table of Contents |
| 2 | + |
| 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\_env |
| 18 | + |
| 19 | +<a name="mlagents_envs.envs.unity_gym_env.UnityGymException"></a> |
| 20 | +## UnityGymException Objects |
| 21 | + |
| 22 | +```python |
| 23 | +class UnityGymException(error.Error) |
| 24 | +``` |
| 25 | + |
| 26 | +Any error related to the gym wrapper of ml-agents. |
| 27 | + |
| 28 | +<a name="mlagents_envs.envs.unity_gym_env.UnityToGymWrapper"></a> |
| 29 | +## UnityToGymWrapper Objects |
| 30 | + |
| 31 | +```python |
| 32 | +class UnityToGymWrapper(gym.Env) |
| 33 | +``` |
| 34 | + |
| 35 | +Provides Gym wrapper for Unity Learning Environments. |
| 36 | + |
| 37 | +<a name="mlagents_envs.envs.unity_gym_env.UnityToGymWrapper.__init__"></a> |
| 38 | +#### \_\_init\_\_ |
| 39 | + |
| 40 | +```python |
| 41 | + | __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 | + |
| 44 | +Environment initialization |
| 45 | + |
| 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 than |
| 51 | + MultiDiscrete. |
| 52 | +- `allow_multiple_obs`: If True, return a list of np.ndarrays as observations with the first elements |
| 53 | + 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 of |
| 55 | + 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 | +#### reset |
| 60 | + |
| 61 | +```python |
| 62 | + | reset() -> Union[List[np.ndarray], np.ndarray] |
| 63 | +``` |
| 64 | + |
| 65 | +Resets the state of the environment and returns an initial observation. |
| 66 | +Returns: observation (object/list): the initial observation of the |
| 67 | +space. |
| 68 | + |
| 69 | +<a name="mlagents_envs.envs.unity_gym_env.UnityToGymWrapper.step"></a> |
| 70 | +#### step |
| 71 | + |
| 72 | +```python |
| 73 | + | step(action: List[Any]) -> GymStepResult |
| 74 | +``` |
| 75 | + |
| 76 | +Run one timestep of the environment's dynamics. When end of |
| 77 | +episode is reached, you are responsible for calling `reset()` |
| 78 | +to reset this environment's state. |
| 79 | +Accepts an action and returns a tuple (observation, reward, done, info). |
| 80 | + |
| 81 | +**Arguments**: |
| 82 | + |
| 83 | +- `action` _object/list_ - an action provided by the environment |
| 84 | + |
| 85 | +**Returns**: |
| 86 | + |
| 87 | +- `observation` _object/list_ - agent's observation of the current environment |
| 88 | + reward (float/list) : amount of reward returned after previous action |
| 89 | +- `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 | +#### render |
| 94 | + |
| 95 | +```python |
| 96 | + | render(mode="rgb_array") |
| 97 | +``` |
| 98 | + |
| 99 | +Return the latest visual observations. |
| 100 | +Note 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 | +#### close |
| 104 | + |
| 105 | +```python |
| 106 | + | close() -> None |
| 107 | +``` |
| 108 | + |
| 109 | +Override _close in your subclass to perform any necessary cleanup. |
| 110 | +Environments will automatically close() themselves when |
| 111 | +garbage collected or when the program exits. |
| 112 | + |
| 113 | +<a name="mlagents_envs.envs.unity_gym_env.UnityToGymWrapper.seed"></a> |
| 114 | +#### seed |
| 115 | + |
| 116 | +```python |
| 117 | + | seed(seed: Any = None) -> None |
| 118 | +``` |
| 119 | + |
| 120 | +Sets the seed for this env's random number generator(s). |
| 121 | +Currently not implemented. |
| 122 | + |
| 123 | +<a name="mlagents_envs.envs.unity_gym_env.ActionFlattener"></a> |
| 124 | +## ActionFlattener Objects |
| 125 | + |
| 126 | +```python |
| 127 | +class ActionFlattener() |
| 128 | +``` |
| 129 | + |
| 130 | +Flattens 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 | +```python |
| 136 | + | __init__(branched_action_space) |
| 137 | +``` |
| 138 | + |
| 139 | +Initialize the flattener. |
| 140 | + |
| 141 | +**Arguments**: |
| 142 | + |
| 143 | +- `branched_action_space`: A List containing the sizes of each branch of the action |
| 144 | +space, 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\_action |
| 148 | + |
| 149 | +```python |
| 150 | + | lookup_action(action) |
| 151 | +``` |
| 152 | + |
| 153 | +Convert 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 | + |
| 161 | +The List containing the branched actions. |
0 commit comments