SIGN IN SIGN UP

The Unity Machine Learning Agents Toolkit (ML-Agents) is an open-source project that enables games and simulations to serve as environments for training intelligent agents using deep reinforcement learning and imitation learning.

0 0 1 C#
Develop python api ga (#6) * Dropped support for python 3.6 * Pinning python 3.9.9 for tests due to typing issues with 3.9.10 * Testing new bokken image. * Testing new bokken image. * Updated yamato standalone build test. * Updated yamato standalone build test. * Updated standalone build test. * Updated yamato configs to use mla bokken vm. * Bug fixes for yamato yml files. * Fixed com.unity.ml-agents-test.yml * Bumped min python version to 3.7.2 * pettingzoo api prototype * add example * update file names * support multiple behavior names * fix multi behavior action index * add install in colab * add setup * update colab * fix __init__ * clone single branch * import tags only * import in init * catch import error * update colab * move colab and add readme * handle agent dying * add tests * update doc * add info * add action mask * fix action mask * update action masks in colab * change default env * set version * fix hybrid action * fix colab for hybrid actions * add note on auto reset * Updated colab name. * Update README.md * Following petting_zoo registry API (#5557) * init petting_zoo registry * cherrypick Custom trainer editor analytics (#5511) * cherrypick "Update dotnet-format to address breaking changes introduced by upstream changes (#5528)" * Update colab to match pettingZoo import api * ToRevert: pull exp-petting-registry branch * Add init file to tests * Install pettingzoo-unity requirements for pytest * update pytest command * Add docstrings and comments * update coverage to pettingzoo folder * unset log level * update env string * Two small bugfixes (#5589) 1. Add the missing `_cumulative_rewards` property 2. Update `agent_selection` to not error out when an agent finishes an episode. * Updated gym to 0.21.0 and petting zoo to 1.13.1, fixed bugs with AEC wrapper for gym and PZ updates. API tests are passing. * Some refactoring. * Finished inital implementation of parallel. Tests not passing. * Finished parallel API implementation and refactor. All PZ tests passing. * Cleanup. * Refactoring. * Pinning numpy version. * add metadata and behavior_specs initialization * addressing behaviour_spec issues * Bumped PZ version to 1.14.0. Fixed failing tests. * Refactored gym-unity and petting-zoo into ml-agents-envs * Added TODO to pydoc-config.yaml * Refactored gym and pz to be under a subpackage in mlagents_env package * Refactored ml-agents-envs docs. * Minor update to PZ API doc. * Updated mlagents_envs docs and colab. * Updated pytest gh workflow to remove ref to gym and pz. * Refactored to remove some test coupling between trainers and envs. * Updated installation doc. * Update ml-agents-envs/README.md Co-authored-by: Andrew Cohen <andrew.cohen@unity3d.com> * Updated failing yamato jobs. * pettingzoo api prototype * add example * update file names * support multiple behavior names * fix multi behavior action index * add install in colab * add setup * update colab * fix __init__ * clone single branch * import tags only * import in init * catch import error * update colab * move colab and add readme * handle agent dying * add tests * update doc * add info * add action mask * fix action mask * update action masks in colab * change default env * set version * fix hybrid action * fix colab for hybrid actions * add note on auto reset * Updated colab name. * Update README.md * Following petting_zoo registry API (#5557) * init petting_zoo registry * cherrypick Custom trainer editor analytics (#5511) * cherrypick "Update dotnet-format to address breaking changes introduced by upstream changes (#5528)" * Update colab to match pettingZoo import api * ToRevert: pull exp-petting-registry branch * Add init file to tests * Install pettingzoo-unity requirements for pytest * update pytest command * Add docstrings and comments * update coverage to pettingzoo folder * unset log level * update env string * Two small bugfixes (#5589) 1. Add the missing `_cumulative_rewards` property 2. Update `agent_selection` to not error out when an agent finishes an episode. * Updated gym to 0.21.0 and petting zoo to 1.13.1, fixed bugs with AEC wrapper for gym and PZ updates. API tests are passing. * Some refactoring. * Finished inital implementation of parallel. Tests not passing. * Finished parallel API implementation and refactor. All PZ tests passing. * Cleanup. * Refactoring. * Pinning numpy version. * add metadata and behavior_specs initialization * addressing behaviour_spec issues * Bumped PZ version to 1.14.0. Fixed failing tests. * Refactored gym-unity and petting-zoo into ml-agents-envs * Added TODO to pydoc-config.yaml * Refactored gym and pz to be under a subpackage in mlagents_env package * Refactored ml-agents-envs docs. * Minor update to PZ API doc. * Updated mlagents_envs docs and colab. * Updated pytest gh workflow to remove ref to gym and pz. * Refactored to remove some test coupling between trainers and envs. * Updated installation doc. * Update ml-agents-envs/README.md Co-authored-by: Andrew Cohen <andrew.cohen@unity3d.com> * Updated CHANGELOG. * Updated Migration guide. * Doc updates based on CR. * Updated github workflow for colab tests. * Updated github workflow for colab tests. * Updated github workflow for colab tests. * Fixed yamato import error. Co-authored-by: Ruo-Ping Dong <ruoping.dong@unity3d.com> Co-authored-by: Miguel Alonso Jr <miguelalonsojr> Co-authored-by: jmercado1985 <75792879+jmercado1985@users.noreply.github.com> Co-authored-by: Maryam Honari <honari.m94@gmail.com> Co-authored-by: Henry Peteet <henry.peteet@unity3d.com> Co-authored-by: mahon94 <maryam.honari@unity3d.com> Co-authored-by: Andrew Cohen <andrew.cohen@unity3d.com>
2022-02-02 19:32:23 -05:00
# Table of Contents
* [mlagents\_envs.envs.unity\_gym\_env](#mlagents_envs.envs.unity_gym_env)
* [UnityGymException](#mlagents_envs.envs.unity_gym_env.UnityGymException)
* [UnityToGymWrapper](#mlagents_envs.envs.unity_gym_env.UnityToGymWrapper)
* [\_\_init\_\_](#mlagents_envs.envs.unity_gym_env.UnityToGymWrapper.__init__)
* [reset](#mlagents_envs.envs.unity_gym_env.UnityToGymWrapper.reset)
* [step](#mlagents_envs.envs.unity_gym_env.UnityToGymWrapper.step)
* [render](#mlagents_envs.envs.unity_gym_env.UnityToGymWrapper.render)
* [close](#mlagents_envs.envs.unity_gym_env.UnityToGymWrapper.close)
* [seed](#mlagents_envs.envs.unity_gym_env.UnityToGymWrapper.seed)
* [ActionFlattener](#mlagents_envs.envs.unity_gym_env.ActionFlattener)
* [\_\_init\_\_](#mlagents_envs.envs.unity_gym_env.ActionFlattener.__init__)
* [lookup\_action](#mlagents_envs.envs.unity_gym_env.ActionFlattener.lookup_action)
<a name="mlagents_envs.envs.unity_gym_env"></a>
# mlagents\_envs.envs.unity\_gym\_env
<a name="mlagents_envs.envs.unity_gym_env.UnityGymException"></a>
## UnityGymException Objects
```python
class UnityGymException(error.Error)
```
Any error related to the gym wrapper of ml-agents.
<a name="mlagents_envs.envs.unity_gym_env.UnityToGymWrapper"></a>
## UnityToGymWrapper Objects
```python
class UnityToGymWrapper(gym.Env)
```
Provides Gym wrapper for Unity Learning Environments.
<a name="mlagents_envs.envs.unity_gym_env.UnityToGymWrapper.__init__"></a>
#### \_\_init\_\_
```python
| __init__(unity_env: BaseEnv, uint8_visual: bool = False, flatten_branched: bool = False, allow_multiple_obs: bool = False, action_space_seed: Optional[int] = None)
```
Environment initialization
**Arguments**:
- `unity_env`: The Unity BaseEnv to be wrapped in the gym. Will be closed when the UnityToGymWrapper closes.
- `uint8_visual`: Return visual observations as uint8 (0-255) matrices instead of float (0.0-1.0).
- `flatten_branched`: If True, turn branched discrete action spaces into a Discrete space rather than
MultiDiscrete.
- `allow_multiple_obs`: If True, return a list of np.ndarrays as observations with the first elements
containing the visual observations and the last element containing the array of vector observations.
If False, returns a single np.ndarray containing either only a single visual observation or the array of
vector observations.
- `action_space_seed`: If non-None, will be used to set the random seed on created gym.Space instances.
<a name="mlagents_envs.envs.unity_gym_env.UnityToGymWrapper.reset"></a>
#### reset
```python
| reset() -> Union[List[np.ndarray], np.ndarray]
```
Resets the state of the environment and returns an initial observation.
Returns: observation (object/list): the initial observation of the
space.
<a name="mlagents_envs.envs.unity_gym_env.UnityToGymWrapper.step"></a>
#### step
```python
| step(action: List[Any]) -> GymStepResult
```
Run one timestep of the environment's dynamics. When end of
episode is reached, you are responsible for calling `reset()`
to reset this environment's state.
Accepts an action and returns a tuple (observation, reward, done, info).
**Arguments**:
- `action` _object/list_ - an action provided by the environment
**Returns**:
- `observation` _object/list_ - agent's observation of the current environment
reward (float/list) : amount of reward returned after previous action
- `done` _boolean/list_ - whether the episode has ended.
- `info` _dict_ - contains auxiliary diagnostic information.
<a name="mlagents_envs.envs.unity_gym_env.UnityToGymWrapper.render"></a>
#### render
```python
| render(mode="rgb_array")
```
Return the latest visual observations.
Note that it will not render a new frame of the environment.
<a name="mlagents_envs.envs.unity_gym_env.UnityToGymWrapper.close"></a>
#### close
```python
| close() -> None
```
Override _close in your subclass to perform any necessary cleanup.
Environments will automatically close() themselves when
garbage collected or when the program exits.
<a name="mlagents_envs.envs.unity_gym_env.UnityToGymWrapper.seed"></a>
#### seed
```python
| seed(seed: Any = None) -> None
```
Sets the seed for this env's random number generator(s).
Currently not implemented.
<a name="mlagents_envs.envs.unity_gym_env.ActionFlattener"></a>
## ActionFlattener Objects
```python
class ActionFlattener()
```
Flattens branched discrete action spaces into single-branch discrete action spaces.
<a name="mlagents_envs.envs.unity_gym_env.ActionFlattener.__init__"></a>
#### \_\_init\_\_
```python
| __init__(branched_action_space)
```
Initialize the flattener.
**Arguments**:
- `branched_action_space`: A List containing the sizes of each branch of the action
space, e.g. [2,3,3] for three branches with size 2, 3, and 3 respectively.
<a name="mlagents_envs.envs.unity_gym_env.ActionFlattener.lookup_action"></a>
#### lookup\_action
```python
| lookup_action(action)
```
Convert a scalar discrete action into a unique set of branched actions.
**Arguments**:
- `action`: A scalar value representing one of the discrete actions.
**Returns**:
The List containing the branched actions.