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 new ll api (#3022) * initial commit for LL-API * fixing ml-agents-envs tests * Implementing action masks * training is fixed for 3DBall * Tests all fixed, gym is broken and missing documentation changes * adding case where no vector obs * Fixed Gym * fixing tests of float64 * fixing float64 * reverting some of brain.py * removing old proto apis * comment type fixes * added properties to AgentGroupSpec and edited the notebooks. * clearing the notebook outputs * Update gym-unity/gym_unity/tests/test_gym.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update gym-unity/gym_unity/tests/test_gym.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * addressing first comments * NaN checks for rewards are back * restoring Union[int, Tuple[int, ...]] for action_shape * Made BatchdStepResult an object * Made _agent_id_to_index private * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * replacing np.array with np.ndarray in typing * adding a new type for AgentGroup and AgentId * fixing brain_info when vec_obs == 0 * Docs ll api (#3047) * LL-API documentation changes * fixes * deleting implementation details * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * edited the migrating docs * Update docs/Migrating.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * adding a period * removing change log
2019-12-09 15:58:26 -08:00
# Unity ML-Agents Python Low Level API
The `mlagents` Python package contains two components: a low level API which
allows you to interact directly with a Unity Environment (`mlagents_envs`) and
an entry point to train (`mlagents-learn`) which allows you to train agents in
Unity Environments using our implementations of reinforcement learning or
imitation learning. This document describes how to use the `mlagents_envs` API.
For information on using `mlagents-learn`, see [here](Training-ML-Agents.md).
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
For Python Low Level API documentation, see [here](Python-LLAPI-Documentation.md).
The Python Low Level API can be used to interact directly with your Unity
learning environment. As such, it can serve as the basis for developing and
evaluating new learning algorithms.
Develop new ll api (#3022) * initial commit for LL-API * fixing ml-agents-envs tests * Implementing action masks * training is fixed for 3DBall * Tests all fixed, gym is broken and missing documentation changes * adding case where no vector obs * Fixed Gym * fixing tests of float64 * fixing float64 * reverting some of brain.py * removing old proto apis * comment type fixes * added properties to AgentGroupSpec and edited the notebooks. * clearing the notebook outputs * Update gym-unity/gym_unity/tests/test_gym.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update gym-unity/gym_unity/tests/test_gym.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * addressing first comments * NaN checks for rewards are back * restoring Union[int, Tuple[int, ...]] for action_shape * Made BatchdStepResult an object * Made _agent_id_to_index private * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * replacing np.array with np.ndarray in typing * adding a new type for AgentGroup and AgentId * fixing brain_info when vec_obs == 0 * Docs ll api (#3047) * LL-API documentation changes * fixes * deleting implementation details * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * edited the migrating docs * Update docs/Migrating.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * adding a period * removing change log
2019-12-09 15:58:26 -08:00
## mlagents_envs
The ML-Agents Toolkit Low Level API is a Python API for controlling the
simulation loop of an environment or game built with Unity. This API is used by
the training algorithms inside the ML-Agent Toolkit, but you can also write your
own Python programs using this API.
The key objects in the Python API include:
- **UnityEnvironment** — the main interface between the Unity application and
your code. Use UnityEnvironment to start and control a simulation or training
session.
WIP : Changes to the LL-API - Refactor of “done” logic (#3681) * [skip ci] WIP : Modify the base_env.py file * [skip ci] typo * [skip ci] renamed some methods * [skip ci] Incorporated changes from our meeting * [skip ci] everything is broken * [skip ci] everything is broken * [skip ci] formatting * Fixing the gym tests * Fixing bug, C# has an error that needs fixing * Fixing the test * relaxing the threshold of 0.99 to 0.9 * fixing the C# side * formating * Fixed the llapi integratio test * [Increasing steps for testing] * Fixing the python tests * Need __contains__ after all * changing the max_steps in the tests * addressing comments * Making env_manager logic clearer as proposed in the comments * Remove duplicated logic and added back in episode length (#3728) * removing mentions of multi-agent in gym and changed the docstring in base_env.py * Edited the Documentation for the changes to the LLAPI (#3733) * Edited the Documentation for the changes to the LLAPI * Forgot the CHANGELOG * Fixing a typo raised by #3731 * [skip ci] Update com.unity.ml-agents/CHANGELOG.md * [skip ci] Update docs/Migrating.md * [skip ci] Update docs/Python-API.md * [skip ci] Update docs/Python-API.md * Resolving silent merge conflicts * [skip ci] Update docs/Python-API.md * [skip ci] Update docs/Python-API.md * [skip ci] Update gym-unity/README.md * [skip ci] Update docs/Python-API.md * Added a sentence asking people to use the llapi instead of gym for multi-agents Co-authored-by: Ervin T <ervin@unity3d.com>
2020-04-06 12:50:32 -07:00
- **BehaviorName** - is a string that identifies a behavior in the simulation.
- **AgentId** - is an `int` that serves as unique identifier for Agents in the
simulation.
- **DecisionSteps** — contains the data from Agents belonging to the same
"Behavior" in the simulation, such as observations and rewards. Only Agents
that requested a decision since the last call to `env.step()` are in the
DecisionSteps object.
- **TerminalSteps** — contains the data from Agents belonging to the same
"Behavior" in the simulation, such as observations and rewards. Only Agents
whose episode ended since the last call to `env.step()` are in the
TerminalSteps object.
- **BehaviorSpec** — describes the shape of the observation data inside
DecisionSteps and TerminalSteps as well as the expected action shapes.
These classes are all defined in the
[base_env](../ml-agents-envs/mlagents_envs/base_env.py) script.
An Agent "Behavior" is a group of Agents identified by a `BehaviorName` that
share the same observations and action types (described in their
`BehaviorSpec`). You can think about Agent Behavior as a group of agents that
will share the same policy. All Agents with the same behavior have the same goal
and reward signals.
To communicate with an Agent in a Unity environment from a Python program, the
Develop new ll api (#3022) * initial commit for LL-API * fixing ml-agents-envs tests * Implementing action masks * training is fixed for 3DBall * Tests all fixed, gym is broken and missing documentation changes * adding case where no vector obs * Fixed Gym * fixing tests of float64 * fixing float64 * reverting some of brain.py * removing old proto apis * comment type fixes * added properties to AgentGroupSpec and edited the notebooks. * clearing the notebook outputs * Update gym-unity/gym_unity/tests/test_gym.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update gym-unity/gym_unity/tests/test_gym.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * addressing first comments * NaN checks for rewards are back * restoring Union[int, Tuple[int, ...]] for action_shape * Made BatchdStepResult an object * Made _agent_id_to_index private * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * replacing np.array with np.ndarray in typing * adding a new type for AgentGroup and AgentId * fixing brain_info when vec_obs == 0 * Docs ll api (#3047) * LL-API documentation changes * fixes * deleting implementation details * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * edited the migrating docs * Update docs/Migrating.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * adding a period * removing change log
2019-12-09 15:58:26 -08:00
Agent in the simulation must have `Behavior Parameters` set to communicate. You
must set the `Behavior Type` to `Default` and give it a `Behavior Name`.
_Notice: Currently communication between Unity and Python takes place over an
open socket without authentication. As such, please make sure that the network
where training takes place is secure. This will be addressed in a future
release._
Develop new ll api (#3022) * initial commit for LL-API * fixing ml-agents-envs tests * Implementing action masks * training is fixed for 3DBall * Tests all fixed, gym is broken and missing documentation changes * adding case where no vector obs * Fixed Gym * fixing tests of float64 * fixing float64 * reverting some of brain.py * removing old proto apis * comment type fixes * added properties to AgentGroupSpec and edited the notebooks. * clearing the notebook outputs * Update gym-unity/gym_unity/tests/test_gym.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update gym-unity/gym_unity/tests/test_gym.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * addressing first comments * NaN checks for rewards are back * restoring Union[int, Tuple[int, ...]] for action_shape * Made BatchdStepResult an object * Made _agent_id_to_index private * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * replacing np.array with np.ndarray in typing * adding a new type for AgentGroup and AgentId * fixing brain_info when vec_obs == 0 * Docs ll api (#3047) * LL-API documentation changes * fixes * deleting implementation details * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * edited the migrating docs * Update docs/Migrating.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * adding a period * removing change log
2019-12-09 15:58:26 -08:00
## Loading a Unity Environment
Python-side communication happens through `UnityEnvironment` which is located in
[`environment.py`](../ml-agents-envs/mlagents_envs/environment.py). To load a
Unity environment from a built binary file, put the file in the same directory
as `envs`. For example, if the filename of your Unity environment is `3DBall`,
in python, run:
```python
from mlagents_envs.environment import UnityEnvironment
# This is a non-blocking call that only loads the environment.
env = UnityEnvironment(file_name="3DBall", seed=1, side_channels=[])
# Start interacting with the environment.
env.reset()
behavior_names = env.behavior_specs.keys()
...
```
**NOTE:** Please read [Interacting with a Unity Environment](#interacting-with-a-unity-environment)
to read more about how you can interact with the Unity environment from Python.
- `file_name` is the name of the environment binary (located in the root
directory of the python project).
- `worker_id` indicates which port to use for communication with the
environment. For use in parallel training regimes such as A3C.
- `seed` indicates the seed to use when generating random numbers during the
training process. In environments which are stochastic, setting the seed
enables reproducible experimentation by ensuring that the environment and
trainers utilize the same random seed.
Develop new ll api (#3022) * initial commit for LL-API * fixing ml-agents-envs tests * Implementing action masks * training is fixed for 3DBall * Tests all fixed, gym is broken and missing documentation changes * adding case where no vector obs * Fixed Gym * fixing tests of float64 * fixing float64 * reverting some of brain.py * removing old proto apis * comment type fixes * added properties to AgentGroupSpec and edited the notebooks. * clearing the notebook outputs * Update gym-unity/gym_unity/tests/test_gym.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update gym-unity/gym_unity/tests/test_gym.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * addressing first comments * NaN checks for rewards are back * restoring Union[int, Tuple[int, ...]] for action_shape * Made BatchdStepResult an object * Made _agent_id_to_index private * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * replacing np.array with np.ndarray in typing * adding a new type for AgentGroup and AgentId * fixing brain_info when vec_obs == 0 * Docs ll api (#3047) * LL-API documentation changes * fixes * deleting implementation details * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * edited the migrating docs * Update docs/Migrating.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * adding a period * removing change log
2019-12-09 15:58:26 -08:00
- `side_channels` provides a way to exchange data with the Unity simulation that
is not related to the reinforcement learning loop. For example: configurations
or properties. More on them in the [Side Channels](Custom-SideChannels.md) doc.
If you want to directly interact with the Editor, you need to use
`file_name=None`, then press the **Play** button in the Editor when the message
_"Start training by pressing the Play button in the Unity Editor"_ is displayed
on the screen
### Interacting with a Unity Environment
Develop new ll api (#3022) * initial commit for LL-API * fixing ml-agents-envs tests * Implementing action masks * training is fixed for 3DBall * Tests all fixed, gym is broken and missing documentation changes * adding case where no vector obs * Fixed Gym * fixing tests of float64 * fixing float64 * reverting some of brain.py * removing old proto apis * comment type fixes * added properties to AgentGroupSpec and edited the notebooks. * clearing the notebook outputs * Update gym-unity/gym_unity/tests/test_gym.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update gym-unity/gym_unity/tests/test_gym.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * addressing first comments * NaN checks for rewards are back * restoring Union[int, Tuple[int, ...]] for action_shape * Made BatchdStepResult an object * Made _agent_id_to_index private * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * replacing np.array with np.ndarray in typing * adding a new type for AgentGroup and AgentId * fixing brain_info when vec_obs == 0 * Docs ll api (#3047) * LL-API documentation changes * fixes * deleting implementation details * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * edited the migrating docs * Update docs/Migrating.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * adding a period * removing change log
2019-12-09 15:58:26 -08:00
#### The BaseEnv interface
A `BaseEnv` has the following methods:
- **Reset : `env.reset()`** Sends a signal to reset the environment. Returns
None.
- **Step : `env.step()`** Sends a signal to step the environment. Returns None.
Note that a "step" for Python does not correspond to either Unity `Update` nor
`FixedUpdate`. When `step()` or `reset()` is called, the Unity simulation will
move forward until an Agent in the simulation needs a input from Python to
act.
- **Close : `env.close()`** Sends a shutdown signal to the environment and
terminates the communication.
- **Behavior Specs : `env.behavior_specs`** Returns a Mapping of
`BehaviorName` to `BehaviorSpec` objects (read only).
A `BehaviorSpec` contains the observation shapes and the
`ActionSpec` (which defines the action shape). Note that
the `BehaviorSpec` for a specific group is fixed throughout the simulation.
The number of entries in the Mapping can change over time in the simulation
if new Agent behaviors are created in the simulation.
- **Get Steps : `env.get_steps(behavior_name: str)`** Returns a tuple
`DecisionSteps, TerminalSteps` corresponding to the behavior_name given as
input. The `DecisionSteps` contains information about the state of the agents
**that need an action this step** and have the behavior behavior_name. The
`TerminalSteps` contains information about the state of the agents **whose
episode ended** and have the behavior behavior_name. Both `DecisionSteps` and
`TerminalSteps` contain information such as the observations, the rewards and
the agent identifiers. `DecisionSteps` also contains action masks for the next
action while `TerminalSteps` contains the reason for termination (did the
Agent reach its maximum step and was interrupted). The data is in `np.array`
of which the first dimension is always the number of agents note that the
number of agents is not guaranteed to remain constant during the simulation
and it is not unusual to have either `DecisionSteps` or `TerminalSteps`
contain no Agents at all.
- **Set Actions :`env.set_actions(behavior_name: str, action: ActionTuple)`** Sets
the actions for a whole agent group. `action` is an `ActionTuple`, which
is made up of a 2D `np.array` of `dtype=np.int32` for discrete actions, and
`dtype=np.float32` for continuous actions. The first dimension of `np.array`
in the tuple is the number of agents that requested a decision since the
last call to `env.step()`. The second dimension is the number of discrete or
continuous actions for the corresponding array.
- **Set Action for Agent :
`env.set_action_for_agent(agent_group: str, agent_id: int, action: ActionTuple)`**
Sets the action for a specific Agent in an agent group. `agent_group` is the
name of the group the Agent belongs to and `agent_id` is the integer
identifier of the Agent. `action` is an `ActionTuple` as described above.
**Note:** If no action is provided for an agent group between two calls to
`env.step()` then the default action will be all zeros.
Develop new ll api (#3022) * initial commit for LL-API * fixing ml-agents-envs tests * Implementing action masks * training is fixed for 3DBall * Tests all fixed, gym is broken and missing documentation changes * adding case where no vector obs * Fixed Gym * fixing tests of float64 * fixing float64 * reverting some of brain.py * removing old proto apis * comment type fixes * added properties to AgentGroupSpec and edited the notebooks. * clearing the notebook outputs * Update gym-unity/gym_unity/tests/test_gym.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update gym-unity/gym_unity/tests/test_gym.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * addressing first comments * NaN checks for rewards are back * restoring Union[int, Tuple[int, ...]] for action_shape * Made BatchdStepResult an object * Made _agent_id_to_index private * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * replacing np.array with np.ndarray in typing * adding a new type for AgentGroup and AgentId * fixing brain_info when vec_obs == 0 * Docs ll api (#3047) * LL-API documentation changes * fixes * deleting implementation details * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * edited the migrating docs * Update docs/Migrating.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * adding a period * removing change log
2019-12-09 15:58:26 -08:00
WIP : Changes to the LL-API - Refactor of “done” logic (#3681) * [skip ci] WIP : Modify the base_env.py file * [skip ci] typo * [skip ci] renamed some methods * [skip ci] Incorporated changes from our meeting * [skip ci] everything is broken * [skip ci] everything is broken * [skip ci] formatting * Fixing the gym tests * Fixing bug, C# has an error that needs fixing * Fixing the test * relaxing the threshold of 0.99 to 0.9 * fixing the C# side * formating * Fixed the llapi integratio test * [Increasing steps for testing] * Fixing the python tests * Need __contains__ after all * changing the max_steps in the tests * addressing comments * Making env_manager logic clearer as proposed in the comments * Remove duplicated logic and added back in episode length (#3728) * removing mentions of multi-agent in gym and changed the docstring in base_env.py * Edited the Documentation for the changes to the LLAPI (#3733) * Edited the Documentation for the changes to the LLAPI * Forgot the CHANGELOG * Fixing a typo raised by #3731 * [skip ci] Update com.unity.ml-agents/CHANGELOG.md * [skip ci] Update docs/Migrating.md * [skip ci] Update docs/Python-API.md * [skip ci] Update docs/Python-API.md * Resolving silent merge conflicts * [skip ci] Update docs/Python-API.md * [skip ci] Update docs/Python-API.md * [skip ci] Update gym-unity/README.md * [skip ci] Update docs/Python-API.md * Added a sentence asking people to use the llapi instead of gym for multi-agents Co-authored-by: Ervin T <ervin@unity3d.com>
2020-04-06 12:50:32 -07:00
#### DecisionSteps and DecisionStep
`DecisionSteps` (with `s`) contains information about a whole batch of Agents
while `DecisionStep` (no `s`) only contains information about a single Agent.
WIP : Changes to the LL-API - Refactor of “done” logic (#3681) * [skip ci] WIP : Modify the base_env.py file * [skip ci] typo * [skip ci] renamed some methods * [skip ci] Incorporated changes from our meeting * [skip ci] everything is broken * [skip ci] everything is broken * [skip ci] formatting * Fixing the gym tests * Fixing bug, C# has an error that needs fixing * Fixing the test * relaxing the threshold of 0.99 to 0.9 * fixing the C# side * formating * Fixed the llapi integratio test * [Increasing steps for testing] * Fixing the python tests * Need __contains__ after all * changing the max_steps in the tests * addressing comments * Making env_manager logic clearer as proposed in the comments * Remove duplicated logic and added back in episode length (#3728) * removing mentions of multi-agent in gym and changed the docstring in base_env.py * Edited the Documentation for the changes to the LLAPI (#3733) * Edited the Documentation for the changes to the LLAPI * Forgot the CHANGELOG * Fixing a typo raised by #3731 * [skip ci] Update com.unity.ml-agents/CHANGELOG.md * [skip ci] Update docs/Migrating.md * [skip ci] Update docs/Python-API.md * [skip ci] Update docs/Python-API.md * Resolving silent merge conflicts * [skip ci] Update docs/Python-API.md * [skip ci] Update docs/Python-API.md * [skip ci] Update gym-unity/README.md * [skip ci] Update docs/Python-API.md * Added a sentence asking people to use the llapi instead of gym for multi-agents Co-authored-by: Ervin T <ervin@unity3d.com>
2020-04-06 12:50:32 -07:00
A `DecisionSteps` has the following fields :
Develop new ll api (#3022) * initial commit for LL-API * fixing ml-agents-envs tests * Implementing action masks * training is fixed for 3DBall * Tests all fixed, gym is broken and missing documentation changes * adding case where no vector obs * Fixed Gym * fixing tests of float64 * fixing float64 * reverting some of brain.py * removing old proto apis * comment type fixes * added properties to AgentGroupSpec and edited the notebooks. * clearing the notebook outputs * Update gym-unity/gym_unity/tests/test_gym.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update gym-unity/gym_unity/tests/test_gym.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * addressing first comments * NaN checks for rewards are back * restoring Union[int, Tuple[int, ...]] for action_shape * Made BatchdStepResult an object * Made _agent_id_to_index private * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * replacing np.array with np.ndarray in typing * adding a new type for AgentGroup and AgentId * fixing brain_info when vec_obs == 0 * Docs ll api (#3047) * LL-API documentation changes * fixes * deleting implementation details * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * edited the migrating docs * Update docs/Migrating.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * adding a period * removing change log
2019-12-09 15:58:26 -08:00
- `obs` is a list of numpy arrays observations collected by the group of agent.
The first dimension of the array corresponds to the batch size of the group
(number of agents requesting a decision since the last call to `env.step()`).
- `reward` is a float vector of length batch size. Corresponds to the rewards
collected by each agent since the last simulation step.
- `agent_id` is an int vector of length batch size containing unique identifier
for the corresponding Agent. This is used to track Agents across simulation
steps.
- `action_mask` is an optional list of two dimensional arrays of booleans which is only
available when using multi-discrete actions. Each array corresponds to an
action branch. The first dimension of each array is the batch size and the
second contains a mask for each action of the branch. If true, the action is
not available for the agent during this simulation step.
Develop new ll api (#3022) * initial commit for LL-API * fixing ml-agents-envs tests * Implementing action masks * training is fixed for 3DBall * Tests all fixed, gym is broken and missing documentation changes * adding case where no vector obs * Fixed Gym * fixing tests of float64 * fixing float64 * reverting some of brain.py * removing old proto apis * comment type fixes * added properties to AgentGroupSpec and edited the notebooks. * clearing the notebook outputs * Update gym-unity/gym_unity/tests/test_gym.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update gym-unity/gym_unity/tests/test_gym.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * addressing first comments * NaN checks for rewards are back * restoring Union[int, Tuple[int, ...]] for action_shape * Made BatchdStepResult an object * Made _agent_id_to_index private * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * replacing np.array with np.ndarray in typing * adding a new type for AgentGroup and AgentId * fixing brain_info when vec_obs == 0 * Docs ll api (#3047) * LL-API documentation changes * fixes * deleting implementation details * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * edited the migrating docs * Update docs/Migrating.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * adding a period * removing change log
2019-12-09 15:58:26 -08:00
It also has the two following methods:
- `len(DecisionSteps)` Returns the number of agents requesting a decision since
the last call to `env.step()`.
- `DecisionSteps[agent_id]` Returns a `DecisionStep` for the Agent with the
`agent_id` unique identifier.
Develop new ll api (#3022) * initial commit for LL-API * fixing ml-agents-envs tests * Implementing action masks * training is fixed for 3DBall * Tests all fixed, gym is broken and missing documentation changes * adding case where no vector obs * Fixed Gym * fixing tests of float64 * fixing float64 * reverting some of brain.py * removing old proto apis * comment type fixes * added properties to AgentGroupSpec and edited the notebooks. * clearing the notebook outputs * Update gym-unity/gym_unity/tests/test_gym.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update gym-unity/gym_unity/tests/test_gym.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * addressing first comments * NaN checks for rewards are back * restoring Union[int, Tuple[int, ...]] for action_shape * Made BatchdStepResult an object * Made _agent_id_to_index private * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * replacing np.array with np.ndarray in typing * adding a new type for AgentGroup and AgentId * fixing brain_info when vec_obs == 0 * Docs ll api (#3047) * LL-API documentation changes * fixes * deleting implementation details * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * edited the migrating docs * Update docs/Migrating.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * adding a period * removing change log
2019-12-09 15:58:26 -08:00
WIP : Changes to the LL-API - Refactor of “done” logic (#3681) * [skip ci] WIP : Modify the base_env.py file * [skip ci] typo * [skip ci] renamed some methods * [skip ci] Incorporated changes from our meeting * [skip ci] everything is broken * [skip ci] everything is broken * [skip ci] formatting * Fixing the gym tests * Fixing bug, C# has an error that needs fixing * Fixing the test * relaxing the threshold of 0.99 to 0.9 * fixing the C# side * formating * Fixed the llapi integratio test * [Increasing steps for testing] * Fixing the python tests * Need __contains__ after all * changing the max_steps in the tests * addressing comments * Making env_manager logic clearer as proposed in the comments * Remove duplicated logic and added back in episode length (#3728) * removing mentions of multi-agent in gym and changed the docstring in base_env.py * Edited the Documentation for the changes to the LLAPI (#3733) * Edited the Documentation for the changes to the LLAPI * Forgot the CHANGELOG * Fixing a typo raised by #3731 * [skip ci] Update com.unity.ml-agents/CHANGELOG.md * [skip ci] Update docs/Migrating.md * [skip ci] Update docs/Python-API.md * [skip ci] Update docs/Python-API.md * Resolving silent merge conflicts * [skip ci] Update docs/Python-API.md * [skip ci] Update docs/Python-API.md * [skip ci] Update gym-unity/README.md * [skip ci] Update docs/Python-API.md * Added a sentence asking people to use the llapi instead of gym for multi-agents Co-authored-by: Ervin T <ervin@unity3d.com>
2020-04-06 12:50:32 -07:00
A `DecisionStep` has the following fields:
Develop new ll api (#3022) * initial commit for LL-API * fixing ml-agents-envs tests * Implementing action masks * training is fixed for 3DBall * Tests all fixed, gym is broken and missing documentation changes * adding case where no vector obs * Fixed Gym * fixing tests of float64 * fixing float64 * reverting some of brain.py * removing old proto apis * comment type fixes * added properties to AgentGroupSpec and edited the notebooks. * clearing the notebook outputs * Update gym-unity/gym_unity/tests/test_gym.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update gym-unity/gym_unity/tests/test_gym.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * addressing first comments * NaN checks for rewards are back * restoring Union[int, Tuple[int, ...]] for action_shape * Made BatchdStepResult an object * Made _agent_id_to_index private * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * replacing np.array with np.ndarray in typing * adding a new type for AgentGroup and AgentId * fixing brain_info when vec_obs == 0 * Docs ll api (#3047) * LL-API documentation changes * fixes * deleting implementation details * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * edited the migrating docs * Update docs/Migrating.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * adding a period * removing change log
2019-12-09 15:58:26 -08:00
- `obs` is a list of numpy arrays observations collected by the agent. (Each
array has one less dimension than the arrays in `DecisionSteps`)
- `reward` is a float. Corresponds to the rewards collected by the agent since
the last simulation step.
- `agent_id` is an int and an unique identifier for the corresponding Agent.
- `action_mask` is an optional list of one dimensional arrays of booleans which is only
available when using multi-discrete actions. Each array corresponds to an
action branch. Each array contains a mask for each action of the branch. If
true, the action is not available for the agent during this simulation step.
Develop new ll api (#3022) * initial commit for LL-API * fixing ml-agents-envs tests * Implementing action masks * training is fixed for 3DBall * Tests all fixed, gym is broken and missing documentation changes * adding case where no vector obs * Fixed Gym * fixing tests of float64 * fixing float64 * reverting some of brain.py * removing old proto apis * comment type fixes * added properties to AgentGroupSpec and edited the notebooks. * clearing the notebook outputs * Update gym-unity/gym_unity/tests/test_gym.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update gym-unity/gym_unity/tests/test_gym.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * addressing first comments * NaN checks for rewards are back * restoring Union[int, Tuple[int, ...]] for action_shape * Made BatchdStepResult an object * Made _agent_id_to_index private * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * replacing np.array with np.ndarray in typing * adding a new type for AgentGroup and AgentId * fixing brain_info when vec_obs == 0 * Docs ll api (#3047) * LL-API documentation changes * fixes * deleting implementation details * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * edited the migrating docs * Update docs/Migrating.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * adding a period * removing change log
2019-12-09 15:58:26 -08:00
WIP : Changes to the LL-API - Refactor of “done” logic (#3681) * [skip ci] WIP : Modify the base_env.py file * [skip ci] typo * [skip ci] renamed some methods * [skip ci] Incorporated changes from our meeting * [skip ci] everything is broken * [skip ci] everything is broken * [skip ci] formatting * Fixing the gym tests * Fixing bug, C# has an error that needs fixing * Fixing the test * relaxing the threshold of 0.99 to 0.9 * fixing the C# side * formating * Fixed the llapi integratio test * [Increasing steps for testing] * Fixing the python tests * Need __contains__ after all * changing the max_steps in the tests * addressing comments * Making env_manager logic clearer as proposed in the comments * Remove duplicated logic and added back in episode length (#3728) * removing mentions of multi-agent in gym and changed the docstring in base_env.py * Edited the Documentation for the changes to the LLAPI (#3733) * Edited the Documentation for the changes to the LLAPI * Forgot the CHANGELOG * Fixing a typo raised by #3731 * [skip ci] Update com.unity.ml-agents/CHANGELOG.md * [skip ci] Update docs/Migrating.md * [skip ci] Update docs/Python-API.md * [skip ci] Update docs/Python-API.md * Resolving silent merge conflicts * [skip ci] Update docs/Python-API.md * [skip ci] Update docs/Python-API.md * [skip ci] Update gym-unity/README.md * [skip ci] Update docs/Python-API.md * Added a sentence asking people to use the llapi instead of gym for multi-agents Co-authored-by: Ervin T <ervin@unity3d.com>
2020-04-06 12:50:32 -07:00
#### TerminalSteps and TerminalStep
Similarly to `DecisionSteps` and `DecisionStep`, `TerminalSteps` (with `s`)
contains information about a whole batch of Agents while `TerminalStep` (no `s`)
only contains information about a single Agent.
Develop new ll api (#3022) * initial commit for LL-API * fixing ml-agents-envs tests * Implementing action masks * training is fixed for 3DBall * Tests all fixed, gym is broken and missing documentation changes * adding case where no vector obs * Fixed Gym * fixing tests of float64 * fixing float64 * reverting some of brain.py * removing old proto apis * comment type fixes * added properties to AgentGroupSpec and edited the notebooks. * clearing the notebook outputs * Update gym-unity/gym_unity/tests/test_gym.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update gym-unity/gym_unity/tests/test_gym.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * addressing first comments * NaN checks for rewards are back * restoring Union[int, Tuple[int, ...]] for action_shape * Made BatchdStepResult an object * Made _agent_id_to_index private * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * replacing np.array with np.ndarray in typing * adding a new type for AgentGroup and AgentId * fixing brain_info when vec_obs == 0 * Docs ll api (#3047) * LL-API documentation changes * fixes * deleting implementation details * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * edited the migrating docs * Update docs/Migrating.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * adding a period * removing change log
2019-12-09 15:58:26 -08:00
WIP : Changes to the LL-API - Refactor of “done” logic (#3681) * [skip ci] WIP : Modify the base_env.py file * [skip ci] typo * [skip ci] renamed some methods * [skip ci] Incorporated changes from our meeting * [skip ci] everything is broken * [skip ci] everything is broken * [skip ci] formatting * Fixing the gym tests * Fixing bug, C# has an error that needs fixing * Fixing the test * relaxing the threshold of 0.99 to 0.9 * fixing the C# side * formating * Fixed the llapi integratio test * [Increasing steps for testing] * Fixing the python tests * Need __contains__ after all * changing the max_steps in the tests * addressing comments * Making env_manager logic clearer as proposed in the comments * Remove duplicated logic and added back in episode length (#3728) * removing mentions of multi-agent in gym and changed the docstring in base_env.py * Edited the Documentation for the changes to the LLAPI (#3733) * Edited the Documentation for the changes to the LLAPI * Forgot the CHANGELOG * Fixing a typo raised by #3731 * [skip ci] Update com.unity.ml-agents/CHANGELOG.md * [skip ci] Update docs/Migrating.md * [skip ci] Update docs/Python-API.md * [skip ci] Update docs/Python-API.md * Resolving silent merge conflicts * [skip ci] Update docs/Python-API.md * [skip ci] Update docs/Python-API.md * [skip ci] Update gym-unity/README.md * [skip ci] Update docs/Python-API.md * Added a sentence asking people to use the llapi instead of gym for multi-agents Co-authored-by: Ervin T <ervin@unity3d.com>
2020-04-06 12:50:32 -07:00
A `TerminalSteps` has the following fields :
- `obs` is a list of numpy arrays observations collected by the group of agent.
The first dimension of the array corresponds to the batch size of the group
(number of agents requesting a decision since the last call to `env.step()`).
- `reward` is a float vector of length batch size. Corresponds to the rewards
collected by each agent since the last simulation step.
- `agent_id` is an int vector of length batch size containing unique identifier
for the corresponding Agent. This is used to track Agents across simulation
steps.
- `interrupted` is an array of booleans of length batch size. Is true if the
associated Agent was interrupted since the last decision step. For example,
if the Agent reached the maximum number of steps for the episode.
WIP : Changes to the LL-API - Refactor of “done” logic (#3681) * [skip ci] WIP : Modify the base_env.py file * [skip ci] typo * [skip ci] renamed some methods * [skip ci] Incorporated changes from our meeting * [skip ci] everything is broken * [skip ci] everything is broken * [skip ci] formatting * Fixing the gym tests * Fixing bug, C# has an error that needs fixing * Fixing the test * relaxing the threshold of 0.99 to 0.9 * fixing the C# side * formating * Fixed the llapi integratio test * [Increasing steps for testing] * Fixing the python tests * Need __contains__ after all * changing the max_steps in the tests * addressing comments * Making env_manager logic clearer as proposed in the comments * Remove duplicated logic and added back in episode length (#3728) * removing mentions of multi-agent in gym and changed the docstring in base_env.py * Edited the Documentation for the changes to the LLAPI (#3733) * Edited the Documentation for the changes to the LLAPI * Forgot the CHANGELOG * Fixing a typo raised by #3731 * [skip ci] Update com.unity.ml-agents/CHANGELOG.md * [skip ci] Update docs/Migrating.md * [skip ci] Update docs/Python-API.md * [skip ci] Update docs/Python-API.md * Resolving silent merge conflicts * [skip ci] Update docs/Python-API.md * [skip ci] Update docs/Python-API.md * [skip ci] Update gym-unity/README.md * [skip ci] Update docs/Python-API.md * Added a sentence asking people to use the llapi instead of gym for multi-agents Co-authored-by: Ervin T <ervin@unity3d.com>
2020-04-06 12:50:32 -07:00
It also has the two following methods:
- `len(TerminalSteps)` Returns the number of agents requesting a decision since
the last call to `env.step()`.
- `TerminalSteps[agent_id]` Returns a `TerminalStep` for the Agent with the
`agent_id` unique identifier.
WIP : Changes to the LL-API - Refactor of “done” logic (#3681) * [skip ci] WIP : Modify the base_env.py file * [skip ci] typo * [skip ci] renamed some methods * [skip ci] Incorporated changes from our meeting * [skip ci] everything is broken * [skip ci] everything is broken * [skip ci] formatting * Fixing the gym tests * Fixing bug, C# has an error that needs fixing * Fixing the test * relaxing the threshold of 0.99 to 0.9 * fixing the C# side * formating * Fixed the llapi integratio test * [Increasing steps for testing] * Fixing the python tests * Need __contains__ after all * changing the max_steps in the tests * addressing comments * Making env_manager logic clearer as proposed in the comments * Remove duplicated logic and added back in episode length (#3728) * removing mentions of multi-agent in gym and changed the docstring in base_env.py * Edited the Documentation for the changes to the LLAPI (#3733) * Edited the Documentation for the changes to the LLAPI * Forgot the CHANGELOG * Fixing a typo raised by #3731 * [skip ci] Update com.unity.ml-agents/CHANGELOG.md * [skip ci] Update docs/Migrating.md * [skip ci] Update docs/Python-API.md * [skip ci] Update docs/Python-API.md * Resolving silent merge conflicts * [skip ci] Update docs/Python-API.md * [skip ci] Update docs/Python-API.md * [skip ci] Update gym-unity/README.md * [skip ci] Update docs/Python-API.md * Added a sentence asking people to use the llapi instead of gym for multi-agents Co-authored-by: Ervin T <ervin@unity3d.com>
2020-04-06 12:50:32 -07:00
A `TerminalStep` has the following fields:
- `obs` is a list of numpy arrays observations collected by the agent. (Each
array has one less dimension than the arrays in `TerminalSteps`)
- `reward` is a float. Corresponds to the rewards collected by the agent since
the last simulation step.
- `agent_id` is an int and an unique identifier for the corresponding Agent.
- `interrupted` is a bool. Is true if the Agent was interrupted since the last
decision step. For example, if the Agent reached the maximum number of steps for
the episode.
WIP : Changes to the LL-API - Refactor of “done” logic (#3681) * [skip ci] WIP : Modify the base_env.py file * [skip ci] typo * [skip ci] renamed some methods * [skip ci] Incorporated changes from our meeting * [skip ci] everything is broken * [skip ci] everything is broken * [skip ci] formatting * Fixing the gym tests * Fixing bug, C# has an error that needs fixing * Fixing the test * relaxing the threshold of 0.99 to 0.9 * fixing the C# side * formating * Fixed the llapi integratio test * [Increasing steps for testing] * Fixing the python tests * Need __contains__ after all * changing the max_steps in the tests * addressing comments * Making env_manager logic clearer as proposed in the comments * Remove duplicated logic and added back in episode length (#3728) * removing mentions of multi-agent in gym and changed the docstring in base_env.py * Edited the Documentation for the changes to the LLAPI (#3733) * Edited the Documentation for the changes to the LLAPI * Forgot the CHANGELOG * Fixing a typo raised by #3731 * [skip ci] Update com.unity.ml-agents/CHANGELOG.md * [skip ci] Update docs/Migrating.md * [skip ci] Update docs/Python-API.md * [skip ci] Update docs/Python-API.md * Resolving silent merge conflicts * [skip ci] Update docs/Python-API.md * [skip ci] Update docs/Python-API.md * [skip ci] Update gym-unity/README.md * [skip ci] Update docs/Python-API.md * Added a sentence asking people to use the llapi instead of gym for multi-agents Co-authored-by: Ervin T <ervin@unity3d.com>
2020-04-06 12:50:32 -07:00
#### BehaviorSpec
A `BehaviorSpec` has the following fields :
Develop new ll api (#3022) * initial commit for LL-API * fixing ml-agents-envs tests * Implementing action masks * training is fixed for 3DBall * Tests all fixed, gym is broken and missing documentation changes * adding case where no vector obs * Fixed Gym * fixing tests of float64 * fixing float64 * reverting some of brain.py * removing old proto apis * comment type fixes * added properties to AgentGroupSpec and edited the notebooks. * clearing the notebook outputs * Update gym-unity/gym_unity/tests/test_gym.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update gym-unity/gym_unity/tests/test_gym.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * addressing first comments * NaN checks for rewards are back * restoring Union[int, Tuple[int, ...]] for action_shape * Made BatchdStepResult an object * Made _agent_id_to_index private * Update ml-agents-envs/mlagents/envs/base_env.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * replacing np.array with np.ndarray in typing * adding a new type for AgentGroup and AgentId * fixing brain_info when vec_obs == 0 * Docs ll api (#3047) * LL-API documentation changes * fixes * deleting implementation details * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * edited the migrating docs * Update docs/Migrating.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * adding a period * removing change log
2019-12-09 15:58:26 -08:00
2021-01-07 11:25:59 -08:00
- `observation_specs` is a List of `ObservationSpec` objects : Each `ObservationSpec`
2020-12-22 09:01:30 -08:00
corresponds to an observation's properties: `shape` is a tuple of ints that
corresponds to the shape of the observation (without the number of agents dimension).
`dimension_property` is a tuple of flags containing extra information about how the
2021-01-07 11:25:59 -08:00
data should be processed in the corresponding dimension. `observation_type` is an enum
corresponding to what type of observation is generating the data (i.e., default, goal,
etc). Note that the `ObservationSpec` have the same ordering as the ordering of observations
2021-01-05 14:33:04 -08:00
in the DecisionSteps, DecisionStep, TerminalSteps and TerminalStep.
- `action_spec` is an `ActionSpec` namedtuple that defines the number and types
of actions for the Agent.
An `ActionSpec` has the following fields and properties:
- `continuous_size` is the number of floats that constitute the continuous actions.
- `discrete_size` is the number of branches (the number of independent actions) that
constitute the multi-discrete actions.
- `discrete_branches` is a Tuple of ints. Each int corresponds to the number of
different options for each branch of the action. For example:
In a game direction input (no movement, left, right) and
jump input (no jump, jump) there will be two branches (direction and jump),
the first one with 3 options and the second with 2 options. (`discrete_size = 2`
and `discrete_action_branches = (3,2,)`)
### Communicating additional information with the Environment
WIP : Changes to the LL-API - Refactor of “done” logic (#3681) * [skip ci] WIP : Modify the base_env.py file * [skip ci] typo * [skip ci] renamed some methods * [skip ci] Incorporated changes from our meeting * [skip ci] everything is broken * [skip ci] everything is broken * [skip ci] formatting * Fixing the gym tests * Fixing bug, C# has an error that needs fixing * Fixing the test * relaxing the threshold of 0.99 to 0.9 * fixing the C# side * formating * Fixed the llapi integratio test * [Increasing steps for testing] * Fixing the python tests * Need __contains__ after all * changing the max_steps in the tests * addressing comments * Making env_manager logic clearer as proposed in the comments * Remove duplicated logic and added back in episode length (#3728) * removing mentions of multi-agent in gym and changed the docstring in base_env.py * Edited the Documentation for the changes to the LLAPI (#3733) * Edited the Documentation for the changes to the LLAPI * Forgot the CHANGELOG * Fixing a typo raised by #3731 * [skip ci] Update com.unity.ml-agents/CHANGELOG.md * [skip ci] Update docs/Migrating.md * [skip ci] Update docs/Python-API.md * [skip ci] Update docs/Python-API.md * Resolving silent merge conflicts * [skip ci] Update docs/Python-API.md * [skip ci] Update docs/Python-API.md * [skip ci] Update gym-unity/README.md * [skip ci] Update docs/Python-API.md * Added a sentence asking people to use the llapi instead of gym for multi-agents Co-authored-by: Ervin T <ervin@unity3d.com>
2020-04-06 12:50:32 -07:00
In addition to the means of communicating between Unity and python described
above, we also provide methods for sharing agent-agnostic information. These
additional methods are referred to as side channels. ML-Agents includes two
ready-made side channels, described below. It is also possible to create custom
side channels to communicate any additional data between a Unity environment and
Python. Instructions for creating custom side channels can be found
[here](Custom-SideChannels.md).
Develop side channels: migrate reset parameters (#2990) * [WIP] Side Channel initial layout * Working prototype for raw bytes * fixing format mistake * Added some errors and some unit tests in C# * Added the side channel for the Engine Configuration. (#2958) * Added the side channel for the Engine Configuration. Note that this change does not require modifying a lot of files : - Adding a sender in Python - Adding a receiver in C# - subscribe the receiver to the communicator (here is a one liner in the Academy) - Add the side channel to the Python UnityEnvironment (not represented here) Adding the side channel to the environment would look like such : ```python from mlagents.envs.environment import UnityEnvironment from mlagents.envs.side_channel.raw_bytes_channel import RawBytesChannel from mlagents.envs.side_channel.engine_configuration_channel import EngineConfigurationChannel channel0 = RawBytesChannel() channel1 = EngineConfigurationChannel() env = UnityEnvironment(base_port = 5004, side_channels = [channel0, channel1]) ``` * renamings * addressing comments * Logging a message when an unknown side channel number has been received by Unity * Addressing comments * renamings * renamings * Adding FloatProperties to the side channels (#2968) * renaming m_SideChannelsDict to m_SideChannel * renaming and some comments * renaming and adding a GetAndClearReceivedMessages() in the RawBytesSideChannel * micro-optimization * more errors and some nit * addressing comments * Using little-endian format in Python * adding some comments * Code comments * some changes and added the unit tests on both Python and C# * removing default default in get default * Update UnitySDK/Assets/ML-Agents/Scripts/SideChannel/SideChannel.cs Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/side_channel/raw_bytes_channel.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * addressing comments * fixing tests * removing the arguments to reset and the property reset_parameters on the UnityEnvironment * curriculum works but removed the check for reset parameters in the scene * processing side channels before the reset command * Removing engine configuration from C# * Engine configuration removed * fixing the tests * Update ml-agents-envs/mlagents/envs/subprocess_env_manager.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing register callbacks with empty calls in FloarProperties * Clamp instead of min max * removing the brain names from the environment.py print * renaming reset_parameters to get properties * made a default engine config * bug fix * Empty commit * Docs changes for the Side Channels feature (#3011) * Docs changes for the Side Channels feature * replace deprecated with removed on the CustomResetPratmeters` * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update docs/Training-Generalized-Reinforcement-Learning-Agents.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing the console outputs in the docs * Update docs/Training-ML-Agents.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * replace does not work with ignored * adding a note on side channels * adding some steps to migrate * addressing comments * adding more docs to the LL-API * added a blob on how to access the properties in C# * adding space between ResetParameters * fix typo * bug fixes * addressing comments
2019-12-03 16:40:01 -08:00
Side channels exist as separate classes which are instantiated, and then passed
as list to the `side_channels` argument of the constructor of the
`UnityEnvironment` class.
```python
channel = MyChannel()
env = UnityEnvironment(side_channels = [channel])
```
**Note** : A side channel will only send/receive messages when `env.step` or
`env.reset()` is called.
Develop side channels: migrate reset parameters (#2990) * [WIP] Side Channel initial layout * Working prototype for raw bytes * fixing format mistake * Added some errors and some unit tests in C# * Added the side channel for the Engine Configuration. (#2958) * Added the side channel for the Engine Configuration. Note that this change does not require modifying a lot of files : - Adding a sender in Python - Adding a receiver in C# - subscribe the receiver to the communicator (here is a one liner in the Academy) - Add the side channel to the Python UnityEnvironment (not represented here) Adding the side channel to the environment would look like such : ```python from mlagents.envs.environment import UnityEnvironment from mlagents.envs.side_channel.raw_bytes_channel import RawBytesChannel from mlagents.envs.side_channel.engine_configuration_channel import EngineConfigurationChannel channel0 = RawBytesChannel() channel1 = EngineConfigurationChannel() env = UnityEnvironment(base_port = 5004, side_channels = [channel0, channel1]) ``` * renamings * addressing comments * Logging a message when an unknown side channel number has been received by Unity * Addressing comments * renamings * renamings * Adding FloatProperties to the side channels (#2968) * renaming m_SideChannelsDict to m_SideChannel * renaming and some comments * renaming and adding a GetAndClearReceivedMessages() in the RawBytesSideChannel * micro-optimization * more errors and some nit * addressing comments * Using little-endian format in Python * adding some comments * Code comments * some changes and added the unit tests on both Python and C# * removing default default in get default * Update UnitySDK/Assets/ML-Agents/Scripts/SideChannel/SideChannel.cs Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/side_channel/raw_bytes_channel.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * addressing comments * fixing tests * removing the arguments to reset and the property reset_parameters on the UnityEnvironment * curriculum works but removed the check for reset parameters in the scene * processing side channels before the reset command * Removing engine configuration from C# * Engine configuration removed * fixing the tests * Update ml-agents-envs/mlagents/envs/subprocess_env_manager.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing register callbacks with empty calls in FloarProperties * Clamp instead of min max * removing the brain names from the environment.py print * renaming reset_parameters to get properties * made a default engine config * bug fix * Empty commit * Docs changes for the Side Channels feature (#3011) * Docs changes for the Side Channels feature * replace deprecated with removed on the CustomResetPratmeters` * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update docs/Training-Generalized-Reinforcement-Learning-Agents.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing the console outputs in the docs * Update docs/Training-ML-Agents.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * replace does not work with ignored * adding a note on side channels * adding some steps to migrate * addressing comments * adding more docs to the LL-API * added a blob on how to access the properties in C# * adding space between ResetParameters * fix typo * bug fixes * addressing comments
2019-12-03 16:40:01 -08:00
#### EngineConfigurationChannel
The `EngineConfiguration` side channel allows you to modify the time-scale,
resolution, and graphics quality of the environment. This can be useful for
adjusting the environment to perform better during training, or be more
interpretable during inference.
Develop side channels: migrate reset parameters (#2990) * [WIP] Side Channel initial layout * Working prototype for raw bytes * fixing format mistake * Added some errors and some unit tests in C# * Added the side channel for the Engine Configuration. (#2958) * Added the side channel for the Engine Configuration. Note that this change does not require modifying a lot of files : - Adding a sender in Python - Adding a receiver in C# - subscribe the receiver to the communicator (here is a one liner in the Academy) - Add the side channel to the Python UnityEnvironment (not represented here) Adding the side channel to the environment would look like such : ```python from mlagents.envs.environment import UnityEnvironment from mlagents.envs.side_channel.raw_bytes_channel import RawBytesChannel from mlagents.envs.side_channel.engine_configuration_channel import EngineConfigurationChannel channel0 = RawBytesChannel() channel1 = EngineConfigurationChannel() env = UnityEnvironment(base_port = 5004, side_channels = [channel0, channel1]) ``` * renamings * addressing comments * Logging a message when an unknown side channel number has been received by Unity * Addressing comments * renamings * renamings * Adding FloatProperties to the side channels (#2968) * renaming m_SideChannelsDict to m_SideChannel * renaming and some comments * renaming and adding a GetAndClearReceivedMessages() in the RawBytesSideChannel * micro-optimization * more errors and some nit * addressing comments * Using little-endian format in Python * adding some comments * Code comments * some changes and added the unit tests on both Python and C# * removing default default in get default * Update UnitySDK/Assets/ML-Agents/Scripts/SideChannel/SideChannel.cs Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/side_channel/raw_bytes_channel.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * addressing comments * fixing tests * removing the arguments to reset and the property reset_parameters on the UnityEnvironment * curriculum works but removed the check for reset parameters in the scene * processing side channels before the reset command * Removing engine configuration from C# * Engine configuration removed * fixing the tests * Update ml-agents-envs/mlagents/envs/subprocess_env_manager.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing register callbacks with empty calls in FloarProperties * Clamp instead of min max * removing the brain names from the environment.py print * renaming reset_parameters to get properties * made a default engine config * bug fix * Empty commit * Docs changes for the Side Channels feature (#3011) * Docs changes for the Side Channels feature * replace deprecated with removed on the CustomResetPratmeters` * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update docs/Training-Generalized-Reinforcement-Learning-Agents.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing the console outputs in the docs * Update docs/Training-ML-Agents.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * replace does not work with ignored * adding a note on side channels * adding some steps to migrate * addressing comments * adding more docs to the LL-API * added a blob on how to access the properties in C# * adding space between ResetParameters * fix typo * bug fixes * addressing comments
2019-12-03 16:40:01 -08:00
`EngineConfigurationChannel` has two methods :
Develop side channels: migrate reset parameters (#2990) * [WIP] Side Channel initial layout * Working prototype for raw bytes * fixing format mistake * Added some errors and some unit tests in C# * Added the side channel for the Engine Configuration. (#2958) * Added the side channel for the Engine Configuration. Note that this change does not require modifying a lot of files : - Adding a sender in Python - Adding a receiver in C# - subscribe the receiver to the communicator (here is a one liner in the Academy) - Add the side channel to the Python UnityEnvironment (not represented here) Adding the side channel to the environment would look like such : ```python from mlagents.envs.environment import UnityEnvironment from mlagents.envs.side_channel.raw_bytes_channel import RawBytesChannel from mlagents.envs.side_channel.engine_configuration_channel import EngineConfigurationChannel channel0 = RawBytesChannel() channel1 = EngineConfigurationChannel() env = UnityEnvironment(base_port = 5004, side_channels = [channel0, channel1]) ``` * renamings * addressing comments * Logging a message when an unknown side channel number has been received by Unity * Addressing comments * renamings * renamings * Adding FloatProperties to the side channels (#2968) * renaming m_SideChannelsDict to m_SideChannel * renaming and some comments * renaming and adding a GetAndClearReceivedMessages() in the RawBytesSideChannel * micro-optimization * more errors and some nit * addressing comments * Using little-endian format in Python * adding some comments * Code comments * some changes and added the unit tests on both Python and C# * removing default default in get default * Update UnitySDK/Assets/ML-Agents/Scripts/SideChannel/SideChannel.cs Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/side_channel/raw_bytes_channel.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * addressing comments * fixing tests * removing the arguments to reset and the property reset_parameters on the UnityEnvironment * curriculum works but removed the check for reset parameters in the scene * processing side channels before the reset command * Removing engine configuration from C# * Engine configuration removed * fixing the tests * Update ml-agents-envs/mlagents/envs/subprocess_env_manager.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing register callbacks with empty calls in FloarProperties * Clamp instead of min max * removing the brain names from the environment.py print * renaming reset_parameters to get properties * made a default engine config * bug fix * Empty commit * Docs changes for the Side Channels feature (#3011) * Docs changes for the Side Channels feature * replace deprecated with removed on the CustomResetPratmeters` * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update docs/Training-Generalized-Reinforcement-Learning-Agents.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing the console outputs in the docs * Update docs/Training-ML-Agents.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * replace does not work with ignored * adding a note on side channels * adding some steps to migrate * addressing comments * adding more docs to the LL-API * added a blob on how to access the properties in C# * adding space between ResetParameters * fix typo * bug fixes * addressing comments
2019-12-03 16:40:01 -08:00
- `set_configuration_parameters` which takes the following arguments:
- `width`: Defines the width of the display. (Must be set alongside height)
- `height`: Defines the height of the display. (Must be set alongside width)
- `quality_level`: Defines the quality level of the simulation.
- `time_scale`: Defines the multiplier for the deltatime in the simulation. If
set to a higher value, time will pass faster in the simulation but the
physics may perform unpredictably.
- `target_frame_rate`: Instructs simulation to try to render at a specified
frame rate.
- `capture_frame_rate` Instructs the simulation to consider time between
updates to always be constant, regardless of the actual frame rate.
- `set_configuration` with argument config which is an `EngineConfig` NamedTuple
object.
For example, the following code would adjust the time-scale of the simulation to
be 2x realtime.
Develop side channels: migrate reset parameters (#2990) * [WIP] Side Channel initial layout * Working prototype for raw bytes * fixing format mistake * Added some errors and some unit tests in C# * Added the side channel for the Engine Configuration. (#2958) * Added the side channel for the Engine Configuration. Note that this change does not require modifying a lot of files : - Adding a sender in Python - Adding a receiver in C# - subscribe the receiver to the communicator (here is a one liner in the Academy) - Add the side channel to the Python UnityEnvironment (not represented here) Adding the side channel to the environment would look like such : ```python from mlagents.envs.environment import UnityEnvironment from mlagents.envs.side_channel.raw_bytes_channel import RawBytesChannel from mlagents.envs.side_channel.engine_configuration_channel import EngineConfigurationChannel channel0 = RawBytesChannel() channel1 = EngineConfigurationChannel() env = UnityEnvironment(base_port = 5004, side_channels = [channel0, channel1]) ``` * renamings * addressing comments * Logging a message when an unknown side channel number has been received by Unity * Addressing comments * renamings * renamings * Adding FloatProperties to the side channels (#2968) * renaming m_SideChannelsDict to m_SideChannel * renaming and some comments * renaming and adding a GetAndClearReceivedMessages() in the RawBytesSideChannel * micro-optimization * more errors and some nit * addressing comments * Using little-endian format in Python * adding some comments * Code comments * some changes and added the unit tests on both Python and C# * removing default default in get default * Update UnitySDK/Assets/ML-Agents/Scripts/SideChannel/SideChannel.cs Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/side_channel/raw_bytes_channel.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * addressing comments * fixing tests * removing the arguments to reset and the property reset_parameters on the UnityEnvironment * curriculum works but removed the check for reset parameters in the scene * processing side channels before the reset command * Removing engine configuration from C# * Engine configuration removed * fixing the tests * Update ml-agents-envs/mlagents/envs/subprocess_env_manager.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing register callbacks with empty calls in FloarProperties * Clamp instead of min max * removing the brain names from the environment.py print * renaming reset_parameters to get properties * made a default engine config * bug fix * Empty commit * Docs changes for the Side Channels feature (#3011) * Docs changes for the Side Channels feature * replace deprecated with removed on the CustomResetPratmeters` * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update docs/Training-Generalized-Reinforcement-Learning-Agents.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing the console outputs in the docs * Update docs/Training-ML-Agents.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * replace does not work with ignored * adding a note on side channels * adding some steps to migrate * addressing comments * adding more docs to the LL-API * added a blob on how to access the properties in C# * adding space between ResetParameters * fix typo * bug fixes * addressing comments
2019-12-03 16:40:01 -08:00
```python
from mlagents_envs.environment import UnityEnvironment
from mlagents_envs.side_channel.engine_configuration_channel import EngineConfigurationChannel
Develop side channels: migrate reset parameters (#2990) * [WIP] Side Channel initial layout * Working prototype for raw bytes * fixing format mistake * Added some errors and some unit tests in C# * Added the side channel for the Engine Configuration. (#2958) * Added the side channel for the Engine Configuration. Note that this change does not require modifying a lot of files : - Adding a sender in Python - Adding a receiver in C# - subscribe the receiver to the communicator (here is a one liner in the Academy) - Add the side channel to the Python UnityEnvironment (not represented here) Adding the side channel to the environment would look like such : ```python from mlagents.envs.environment import UnityEnvironment from mlagents.envs.side_channel.raw_bytes_channel import RawBytesChannel from mlagents.envs.side_channel.engine_configuration_channel import EngineConfigurationChannel channel0 = RawBytesChannel() channel1 = EngineConfigurationChannel() env = UnityEnvironment(base_port = 5004, side_channels = [channel0, channel1]) ``` * renamings * addressing comments * Logging a message when an unknown side channel number has been received by Unity * Addressing comments * renamings * renamings * Adding FloatProperties to the side channels (#2968) * renaming m_SideChannelsDict to m_SideChannel * renaming and some comments * renaming and adding a GetAndClearReceivedMessages() in the RawBytesSideChannel * micro-optimization * more errors and some nit * addressing comments * Using little-endian format in Python * adding some comments * Code comments * some changes and added the unit tests on both Python and C# * removing default default in get default * Update UnitySDK/Assets/ML-Agents/Scripts/SideChannel/SideChannel.cs Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/side_channel/raw_bytes_channel.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * addressing comments * fixing tests * removing the arguments to reset and the property reset_parameters on the UnityEnvironment * curriculum works but removed the check for reset parameters in the scene * processing side channels before the reset command * Removing engine configuration from C# * Engine configuration removed * fixing the tests * Update ml-agents-envs/mlagents/envs/subprocess_env_manager.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing register callbacks with empty calls in FloarProperties * Clamp instead of min max * removing the brain names from the environment.py print * renaming reset_parameters to get properties * made a default engine config * bug fix * Empty commit * Docs changes for the Side Channels feature (#3011) * Docs changes for the Side Channels feature * replace deprecated with removed on the CustomResetPratmeters` * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update docs/Training-Generalized-Reinforcement-Learning-Agents.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing the console outputs in the docs * Update docs/Training-ML-Agents.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * replace does not work with ignored * adding a note on side channels * adding some steps to migrate * addressing comments * adding more docs to the LL-API * added a blob on how to access the properties in C# * adding space between ResetParameters * fix typo * bug fixes * addressing comments
2019-12-03 16:40:01 -08:00
channel = EngineConfigurationChannel()
env = UnityEnvironment(side_channels=[channel])
Develop side channels: migrate reset parameters (#2990) * [WIP] Side Channel initial layout * Working prototype for raw bytes * fixing format mistake * Added some errors and some unit tests in C# * Added the side channel for the Engine Configuration. (#2958) * Added the side channel for the Engine Configuration. Note that this change does not require modifying a lot of files : - Adding a sender in Python - Adding a receiver in C# - subscribe the receiver to the communicator (here is a one liner in the Academy) - Add the side channel to the Python UnityEnvironment (not represented here) Adding the side channel to the environment would look like such : ```python from mlagents.envs.environment import UnityEnvironment from mlagents.envs.side_channel.raw_bytes_channel import RawBytesChannel from mlagents.envs.side_channel.engine_configuration_channel import EngineConfigurationChannel channel0 = RawBytesChannel() channel1 = EngineConfigurationChannel() env = UnityEnvironment(base_port = 5004, side_channels = [channel0, channel1]) ``` * renamings * addressing comments * Logging a message when an unknown side channel number has been received by Unity * Addressing comments * renamings * renamings * Adding FloatProperties to the side channels (#2968) * renaming m_SideChannelsDict to m_SideChannel * renaming and some comments * renaming and adding a GetAndClearReceivedMessages() in the RawBytesSideChannel * micro-optimization * more errors and some nit * addressing comments * Using little-endian format in Python * adding some comments * Code comments * some changes and added the unit tests on both Python and C# * removing default default in get default * Update UnitySDK/Assets/ML-Agents/Scripts/SideChannel/SideChannel.cs Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/side_channel/raw_bytes_channel.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * addressing comments * fixing tests * removing the arguments to reset and the property reset_parameters on the UnityEnvironment * curriculum works but removed the check for reset parameters in the scene * processing side channels before the reset command * Removing engine configuration from C# * Engine configuration removed * fixing the tests * Update ml-agents-envs/mlagents/envs/subprocess_env_manager.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing register callbacks with empty calls in FloarProperties * Clamp instead of min max * removing the brain names from the environment.py print * renaming reset_parameters to get properties * made a default engine config * bug fix * Empty commit * Docs changes for the Side Channels feature (#3011) * Docs changes for the Side Channels feature * replace deprecated with removed on the CustomResetPratmeters` * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update docs/Training-Generalized-Reinforcement-Learning-Agents.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing the console outputs in the docs * Update docs/Training-ML-Agents.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * replace does not work with ignored * adding a note on side channels * adding some steps to migrate * addressing comments * adding more docs to the LL-API * added a blob on how to access the properties in C# * adding space between ResetParameters * fix typo * bug fixes * addressing comments
2019-12-03 16:40:01 -08:00
channel.set_configuration_parameters(time_scale = 2.0)
i = env.reset()
...
```
[WIP] Side Channel Design Changes (#3807) * Make EnvironmentParameters a first-class citizen in the API Missing: Python conterparts and testing. * Minor comment fix to Engine Parameters * A second minor fix. * Make EngineConfigChannel Internal and add a singleton/sealed accessor * Make StatsSideChannel Internal and add a singleton/sealed accessor * Changes to SideChannelUtils - Disallow two sidechannels of the same type to be added - Remove GetSideChannels that return a list as that is now unnecessary - Make most methods except (register/unregister) internal to limit users impacting the “system-level” side channels - Add an improved comment to SideChannel.cs * Added Dispose methods to system-level sidechannel wrappers - Specifically to StatsRecorder, EnvironmentParameters and EngineParameters. - Updated Academy.Dispose to take advantage of these. - Updated Editor tests to cover all three “system-level” side channels. Kudos to Unit Tests (TestAcademy / TestAcademyDispose) for catching these. * Removed debub log. * Back-up commit. * Revert "Back-up commit." This reverts commit f81e835cd314cb14cbc489feb75e430606e0419c. * key changes to wrapper classes made the wrapper classes non-singleton (but internal constructors) made EngineParameters internal * Re-enabled the option to add multiple side channels of the same type * Fixed example env * Add an enum flag to the EnvParamsChannel * Adding .cs.meta files * Update engine config side channel Removed unnecessary accessors Made capture frame rate a parameter * Rename SideChannelUtils —> SideChannelsManager * PR feedback * Minor PR feedback. * Python side changes to the SideChannel redesign (#3826) * Modified the EngineConfig to send one message per field * Created the Python Environment Parameters Channel and hooked it in * Make OnMessageReceived protected * addressing comments * [Side Channels] Edited the documenation and renamed a few things (#3833) * Edited the documetation and renamed a few things * addressing comments * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update com.unity.ml-agents/CHANGELOG.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing unecessary migrating line Co-authored-by: Chris Elion <chris.elion@unity3d.com> * Addressing renaming comments * Removing the EngineParameters class Co-authored-by: Vincent-Pierre BERGES <vincentpierre@unity3d.com> Co-authored-by: Chris Elion <chris.elion@unity3d.com>
2020-04-23 16:46:55 -07:00
#### EnvironmentParameters
The `EnvironmentParameters` will allow you to get and set pre-defined numerical
values in the environment. This can be useful for adjusting environment-specific
settings, or for reading non-agent related information from the environment. You
can call `get_property` and `set_property` on the side channel to read and write
properties.
[WIP] Side Channel Design Changes (#3807) * Make EnvironmentParameters a first-class citizen in the API Missing: Python conterparts and testing. * Minor comment fix to Engine Parameters * A second minor fix. * Make EngineConfigChannel Internal and add a singleton/sealed accessor * Make StatsSideChannel Internal and add a singleton/sealed accessor * Changes to SideChannelUtils - Disallow two sidechannels of the same type to be added - Remove GetSideChannels that return a list as that is now unnecessary - Make most methods except (register/unregister) internal to limit users impacting the “system-level” side channels - Add an improved comment to SideChannel.cs * Added Dispose methods to system-level sidechannel wrappers - Specifically to StatsRecorder, EnvironmentParameters and EngineParameters. - Updated Academy.Dispose to take advantage of these. - Updated Editor tests to cover all three “system-level” side channels. Kudos to Unit Tests (TestAcademy / TestAcademyDispose) for catching these. * Removed debub log. * Back-up commit. * Revert "Back-up commit." This reverts commit f81e835cd314cb14cbc489feb75e430606e0419c. * key changes to wrapper classes made the wrapper classes non-singleton (but internal constructors) made EngineParameters internal * Re-enabled the option to add multiple side channels of the same type * Fixed example env * Add an enum flag to the EnvParamsChannel * Adding .cs.meta files * Update engine config side channel Removed unnecessary accessors Made capture frame rate a parameter * Rename SideChannelUtils —> SideChannelsManager * PR feedback * Minor PR feedback. * Python side changes to the SideChannel redesign (#3826) * Modified the EngineConfig to send one message per field * Created the Python Environment Parameters Channel and hooked it in * Make OnMessageReceived protected * addressing comments * [Side Channels] Edited the documenation and renamed a few things (#3833) * Edited the documetation and renamed a few things * addressing comments * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update com.unity.ml-agents/CHANGELOG.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing unecessary migrating line Co-authored-by: Chris Elion <chris.elion@unity3d.com> * Addressing renaming comments * Removing the EngineParameters class Co-authored-by: Vincent-Pierre BERGES <vincentpierre@unity3d.com> Co-authored-by: Chris Elion <chris.elion@unity3d.com>
2020-04-23 16:46:55 -07:00
`EnvironmentParametersChannel` has one methods:
Develop side channels: migrate reset parameters (#2990) * [WIP] Side Channel initial layout * Working prototype for raw bytes * fixing format mistake * Added some errors and some unit tests in C# * Added the side channel for the Engine Configuration. (#2958) * Added the side channel for the Engine Configuration. Note that this change does not require modifying a lot of files : - Adding a sender in Python - Adding a receiver in C# - subscribe the receiver to the communicator (here is a one liner in the Academy) - Add the side channel to the Python UnityEnvironment (not represented here) Adding the side channel to the environment would look like such : ```python from mlagents.envs.environment import UnityEnvironment from mlagents.envs.side_channel.raw_bytes_channel import RawBytesChannel from mlagents.envs.side_channel.engine_configuration_channel import EngineConfigurationChannel channel0 = RawBytesChannel() channel1 = EngineConfigurationChannel() env = UnityEnvironment(base_port = 5004, side_channels = [channel0, channel1]) ``` * renamings * addressing comments * Logging a message when an unknown side channel number has been received by Unity * Addressing comments * renamings * renamings * Adding FloatProperties to the side channels (#2968) * renaming m_SideChannelsDict to m_SideChannel * renaming and some comments * renaming and adding a GetAndClearReceivedMessages() in the RawBytesSideChannel * micro-optimization * more errors and some nit * addressing comments * Using little-endian format in Python * adding some comments * Code comments * some changes and added the unit tests on both Python and C# * removing default default in get default * Update UnitySDK/Assets/ML-Agents/Scripts/SideChannel/SideChannel.cs Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/side_channel/raw_bytes_channel.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * addressing comments * fixing tests * removing the arguments to reset and the property reset_parameters on the UnityEnvironment * curriculum works but removed the check for reset parameters in the scene * processing side channels before the reset command * Removing engine configuration from C# * Engine configuration removed * fixing the tests * Update ml-agents-envs/mlagents/envs/subprocess_env_manager.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing register callbacks with empty calls in FloarProperties * Clamp instead of min max * removing the brain names from the environment.py print * renaming reset_parameters to get properties * made a default engine config * bug fix * Empty commit * Docs changes for the Side Channels feature (#3011) * Docs changes for the Side Channels feature * replace deprecated with removed on the CustomResetPratmeters` * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update docs/Training-Generalized-Reinforcement-Learning-Agents.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing the console outputs in the docs * Update docs/Training-ML-Agents.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * replace does not work with ignored * adding a note on side channels * adding some steps to migrate * addressing comments * adding more docs to the LL-API * added a blob on how to access the properties in C# * adding space between ResetParameters * fix typo * bug fixes * addressing comments
2019-12-03 16:40:01 -08:00
- `set_float_parameter` Sets a float parameter in the Unity Environment.
- key: The string identifier of the property.
- value: The float value of the property.
Develop side channels: migrate reset parameters (#2990) * [WIP] Side Channel initial layout * Working prototype for raw bytes * fixing format mistake * Added some errors and some unit tests in C# * Added the side channel for the Engine Configuration. (#2958) * Added the side channel for the Engine Configuration. Note that this change does not require modifying a lot of files : - Adding a sender in Python - Adding a receiver in C# - subscribe the receiver to the communicator (here is a one liner in the Academy) - Add the side channel to the Python UnityEnvironment (not represented here) Adding the side channel to the environment would look like such : ```python from mlagents.envs.environment import UnityEnvironment from mlagents.envs.side_channel.raw_bytes_channel import RawBytesChannel from mlagents.envs.side_channel.engine_configuration_channel import EngineConfigurationChannel channel0 = RawBytesChannel() channel1 = EngineConfigurationChannel() env = UnityEnvironment(base_port = 5004, side_channels = [channel0, channel1]) ``` * renamings * addressing comments * Logging a message when an unknown side channel number has been received by Unity * Addressing comments * renamings * renamings * Adding FloatProperties to the side channels (#2968) * renaming m_SideChannelsDict to m_SideChannel * renaming and some comments * renaming and adding a GetAndClearReceivedMessages() in the RawBytesSideChannel * micro-optimization * more errors and some nit * addressing comments * Using little-endian format in Python * adding some comments * Code comments * some changes and added the unit tests on both Python and C# * removing default default in get default * Update UnitySDK/Assets/ML-Agents/Scripts/SideChannel/SideChannel.cs Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/side_channel/raw_bytes_channel.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * addressing comments * fixing tests * removing the arguments to reset and the property reset_parameters on the UnityEnvironment * curriculum works but removed the check for reset parameters in the scene * processing side channels before the reset command * Removing engine configuration from C# * Engine configuration removed * fixing the tests * Update ml-agents-envs/mlagents/envs/subprocess_env_manager.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing register callbacks with empty calls in FloarProperties * Clamp instead of min max * removing the brain names from the environment.py print * renaming reset_parameters to get properties * made a default engine config * bug fix * Empty commit * Docs changes for the Side Channels feature (#3011) * Docs changes for the Side Channels feature * replace deprecated with removed on the CustomResetPratmeters` * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update docs/Training-Generalized-Reinforcement-Learning-Agents.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing the console outputs in the docs * Update docs/Training-ML-Agents.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * replace does not work with ignored * adding a note on side channels * adding some steps to migrate * addressing comments * adding more docs to the LL-API * added a blob on how to access the properties in C# * adding space between ResetParameters * fix typo * bug fixes * addressing comments
2019-12-03 16:40:01 -08:00
```python
from mlagents_envs.environment import UnityEnvironment
[WIP] Side Channel Design Changes (#3807) * Make EnvironmentParameters a first-class citizen in the API Missing: Python conterparts and testing. * Minor comment fix to Engine Parameters * A second minor fix. * Make EngineConfigChannel Internal and add a singleton/sealed accessor * Make StatsSideChannel Internal and add a singleton/sealed accessor * Changes to SideChannelUtils - Disallow two sidechannels of the same type to be added - Remove GetSideChannels that return a list as that is now unnecessary - Make most methods except (register/unregister) internal to limit users impacting the “system-level” side channels - Add an improved comment to SideChannel.cs * Added Dispose methods to system-level sidechannel wrappers - Specifically to StatsRecorder, EnvironmentParameters and EngineParameters. - Updated Academy.Dispose to take advantage of these. - Updated Editor tests to cover all three “system-level” side channels. Kudos to Unit Tests (TestAcademy / TestAcademyDispose) for catching these. * Removed debub log. * Back-up commit. * Revert "Back-up commit." This reverts commit f81e835cd314cb14cbc489feb75e430606e0419c. * key changes to wrapper classes made the wrapper classes non-singleton (but internal constructors) made EngineParameters internal * Re-enabled the option to add multiple side channels of the same type * Fixed example env * Add an enum flag to the EnvParamsChannel * Adding .cs.meta files * Update engine config side channel Removed unnecessary accessors Made capture frame rate a parameter * Rename SideChannelUtils —> SideChannelsManager * PR feedback * Minor PR feedback. * Python side changes to the SideChannel redesign (#3826) * Modified the EngineConfig to send one message per field * Created the Python Environment Parameters Channel and hooked it in * Make OnMessageReceived protected * addressing comments * [Side Channels] Edited the documenation and renamed a few things (#3833) * Edited the documetation and renamed a few things * addressing comments * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update com.unity.ml-agents/CHANGELOG.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing unecessary migrating line Co-authored-by: Chris Elion <chris.elion@unity3d.com> * Addressing renaming comments * Removing the EngineParameters class Co-authored-by: Vincent-Pierre BERGES <vincentpierre@unity3d.com> Co-authored-by: Chris Elion <chris.elion@unity3d.com>
2020-04-23 16:46:55 -07:00
from mlagents_envs.side_channel.environment_parameters_channel import EnvironmentParametersChannel
Develop side channels: migrate reset parameters (#2990) * [WIP] Side Channel initial layout * Working prototype for raw bytes * fixing format mistake * Added some errors and some unit tests in C# * Added the side channel for the Engine Configuration. (#2958) * Added the side channel for the Engine Configuration. Note that this change does not require modifying a lot of files : - Adding a sender in Python - Adding a receiver in C# - subscribe the receiver to the communicator (here is a one liner in the Academy) - Add the side channel to the Python UnityEnvironment (not represented here) Adding the side channel to the environment would look like such : ```python from mlagents.envs.environment import UnityEnvironment from mlagents.envs.side_channel.raw_bytes_channel import RawBytesChannel from mlagents.envs.side_channel.engine_configuration_channel import EngineConfigurationChannel channel0 = RawBytesChannel() channel1 = EngineConfigurationChannel() env = UnityEnvironment(base_port = 5004, side_channels = [channel0, channel1]) ``` * renamings * addressing comments * Logging a message when an unknown side channel number has been received by Unity * Addressing comments * renamings * renamings * Adding FloatProperties to the side channels (#2968) * renaming m_SideChannelsDict to m_SideChannel * renaming and some comments * renaming and adding a GetAndClearReceivedMessages() in the RawBytesSideChannel * micro-optimization * more errors and some nit * addressing comments * Using little-endian format in Python * adding some comments * Code comments * some changes and added the unit tests on both Python and C# * removing default default in get default * Update UnitySDK/Assets/ML-Agents/Scripts/SideChannel/SideChannel.cs Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/side_channel/raw_bytes_channel.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * addressing comments * fixing tests * removing the arguments to reset and the property reset_parameters on the UnityEnvironment * curriculum works but removed the check for reset parameters in the scene * processing side channels before the reset command * Removing engine configuration from C# * Engine configuration removed * fixing the tests * Update ml-agents-envs/mlagents/envs/subprocess_env_manager.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing register callbacks with empty calls in FloarProperties * Clamp instead of min max * removing the brain names from the environment.py print * renaming reset_parameters to get properties * made a default engine config * bug fix * Empty commit * Docs changes for the Side Channels feature (#3011) * Docs changes for the Side Channels feature * replace deprecated with removed on the CustomResetPratmeters` * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update docs/Training-Generalized-Reinforcement-Learning-Agents.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing the console outputs in the docs * Update docs/Training-ML-Agents.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * replace does not work with ignored * adding a note on side channels * adding some steps to migrate * addressing comments * adding more docs to the LL-API * added a blob on how to access the properties in C# * adding space between ResetParameters * fix typo * bug fixes * addressing comments
2019-12-03 16:40:01 -08:00
[WIP] Side Channel Design Changes (#3807) * Make EnvironmentParameters a first-class citizen in the API Missing: Python conterparts and testing. * Minor comment fix to Engine Parameters * A second minor fix. * Make EngineConfigChannel Internal and add a singleton/sealed accessor * Make StatsSideChannel Internal and add a singleton/sealed accessor * Changes to SideChannelUtils - Disallow two sidechannels of the same type to be added - Remove GetSideChannels that return a list as that is now unnecessary - Make most methods except (register/unregister) internal to limit users impacting the “system-level” side channels - Add an improved comment to SideChannel.cs * Added Dispose methods to system-level sidechannel wrappers - Specifically to StatsRecorder, EnvironmentParameters and EngineParameters. - Updated Academy.Dispose to take advantage of these. - Updated Editor tests to cover all three “system-level” side channels. Kudos to Unit Tests (TestAcademy / TestAcademyDispose) for catching these. * Removed debub log. * Back-up commit. * Revert "Back-up commit." This reverts commit f81e835cd314cb14cbc489feb75e430606e0419c. * key changes to wrapper classes made the wrapper classes non-singleton (but internal constructors) made EngineParameters internal * Re-enabled the option to add multiple side channels of the same type * Fixed example env * Add an enum flag to the EnvParamsChannel * Adding .cs.meta files * Update engine config side channel Removed unnecessary accessors Made capture frame rate a parameter * Rename SideChannelUtils —> SideChannelsManager * PR feedback * Minor PR feedback. * Python side changes to the SideChannel redesign (#3826) * Modified the EngineConfig to send one message per field * Created the Python Environment Parameters Channel and hooked it in * Make OnMessageReceived protected * addressing comments * [Side Channels] Edited the documenation and renamed a few things (#3833) * Edited the documetation and renamed a few things * addressing comments * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update com.unity.ml-agents/CHANGELOG.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing unecessary migrating line Co-authored-by: Chris Elion <chris.elion@unity3d.com> * Addressing renaming comments * Removing the EngineParameters class Co-authored-by: Vincent-Pierre BERGES <vincentpierre@unity3d.com> Co-authored-by: Chris Elion <chris.elion@unity3d.com>
2020-04-23 16:46:55 -07:00
channel = EnvironmentParametersChannel()
Develop side channels: migrate reset parameters (#2990) * [WIP] Side Channel initial layout * Working prototype for raw bytes * fixing format mistake * Added some errors and some unit tests in C# * Added the side channel for the Engine Configuration. (#2958) * Added the side channel for the Engine Configuration. Note that this change does not require modifying a lot of files : - Adding a sender in Python - Adding a receiver in C# - subscribe the receiver to the communicator (here is a one liner in the Academy) - Add the side channel to the Python UnityEnvironment (not represented here) Adding the side channel to the environment would look like such : ```python from mlagents.envs.environment import UnityEnvironment from mlagents.envs.side_channel.raw_bytes_channel import RawBytesChannel from mlagents.envs.side_channel.engine_configuration_channel import EngineConfigurationChannel channel0 = RawBytesChannel() channel1 = EngineConfigurationChannel() env = UnityEnvironment(base_port = 5004, side_channels = [channel0, channel1]) ``` * renamings * addressing comments * Logging a message when an unknown side channel number has been received by Unity * Addressing comments * renamings * renamings * Adding FloatProperties to the side channels (#2968) * renaming m_SideChannelsDict to m_SideChannel * renaming and some comments * renaming and adding a GetAndClearReceivedMessages() in the RawBytesSideChannel * micro-optimization * more errors and some nit * addressing comments * Using little-endian format in Python * adding some comments * Code comments * some changes and added the unit tests on both Python and C# * removing default default in get default * Update UnitySDK/Assets/ML-Agents/Scripts/SideChannel/SideChannel.cs Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/side_channel/raw_bytes_channel.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * addressing comments * fixing tests * removing the arguments to reset and the property reset_parameters on the UnityEnvironment * curriculum works but removed the check for reset parameters in the scene * processing side channels before the reset command * Removing engine configuration from C# * Engine configuration removed * fixing the tests * Update ml-agents-envs/mlagents/envs/subprocess_env_manager.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing register callbacks with empty calls in FloarProperties * Clamp instead of min max * removing the brain names from the environment.py print * renaming reset_parameters to get properties * made a default engine config * bug fix * Empty commit * Docs changes for the Side Channels feature (#3011) * Docs changes for the Side Channels feature * replace deprecated with removed on the CustomResetPratmeters` * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update docs/Training-Generalized-Reinforcement-Learning-Agents.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing the console outputs in the docs * Update docs/Training-ML-Agents.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * replace does not work with ignored * adding a note on side channels * adding some steps to migrate * addressing comments * adding more docs to the LL-API * added a blob on how to access the properties in C# * adding space between ResetParameters * fix typo * bug fixes * addressing comments
2019-12-03 16:40:01 -08:00
env = UnityEnvironment(side_channels=[channel])
Develop side channels: migrate reset parameters (#2990) * [WIP] Side Channel initial layout * Working prototype for raw bytes * fixing format mistake * Added some errors and some unit tests in C# * Added the side channel for the Engine Configuration. (#2958) * Added the side channel for the Engine Configuration. Note that this change does not require modifying a lot of files : - Adding a sender in Python - Adding a receiver in C# - subscribe the receiver to the communicator (here is a one liner in the Academy) - Add the side channel to the Python UnityEnvironment (not represented here) Adding the side channel to the environment would look like such : ```python from mlagents.envs.environment import UnityEnvironment from mlagents.envs.side_channel.raw_bytes_channel import RawBytesChannel from mlagents.envs.side_channel.engine_configuration_channel import EngineConfigurationChannel channel0 = RawBytesChannel() channel1 = EngineConfigurationChannel() env = UnityEnvironment(base_port = 5004, side_channels = [channel0, channel1]) ``` * renamings * addressing comments * Logging a message when an unknown side channel number has been received by Unity * Addressing comments * renamings * renamings * Adding FloatProperties to the side channels (#2968) * renaming m_SideChannelsDict to m_SideChannel * renaming and some comments * renaming and adding a GetAndClearReceivedMessages() in the RawBytesSideChannel * micro-optimization * more errors and some nit * addressing comments * Using little-endian format in Python * adding some comments * Code comments * some changes and added the unit tests on both Python and C# * removing default default in get default * Update UnitySDK/Assets/ML-Agents/Scripts/SideChannel/SideChannel.cs Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/side_channel/raw_bytes_channel.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * addressing comments * fixing tests * removing the arguments to reset and the property reset_parameters on the UnityEnvironment * curriculum works but removed the check for reset parameters in the scene * processing side channels before the reset command * Removing engine configuration from C# * Engine configuration removed * fixing the tests * Update ml-agents-envs/mlagents/envs/subprocess_env_manager.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing register callbacks with empty calls in FloarProperties * Clamp instead of min max * removing the brain names from the environment.py print * renaming reset_parameters to get properties * made a default engine config * bug fix * Empty commit * Docs changes for the Side Channels feature (#3011) * Docs changes for the Side Channels feature * replace deprecated with removed on the CustomResetPratmeters` * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update docs/Training-Generalized-Reinforcement-Learning-Agents.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing the console outputs in the docs * Update docs/Training-ML-Agents.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * replace does not work with ignored * adding a note on side channels * adding some steps to migrate * addressing comments * adding more docs to the LL-API * added a blob on how to access the properties in C# * adding space between ResetParameters * fix typo * bug fixes * addressing comments
2019-12-03 16:40:01 -08:00
[WIP] Side Channel Design Changes (#3807) * Make EnvironmentParameters a first-class citizen in the API Missing: Python conterparts and testing. * Minor comment fix to Engine Parameters * A second minor fix. * Make EngineConfigChannel Internal and add a singleton/sealed accessor * Make StatsSideChannel Internal and add a singleton/sealed accessor * Changes to SideChannelUtils - Disallow two sidechannels of the same type to be added - Remove GetSideChannels that return a list as that is now unnecessary - Make most methods except (register/unregister) internal to limit users impacting the “system-level” side channels - Add an improved comment to SideChannel.cs * Added Dispose methods to system-level sidechannel wrappers - Specifically to StatsRecorder, EnvironmentParameters and EngineParameters. - Updated Academy.Dispose to take advantage of these. - Updated Editor tests to cover all three “system-level” side channels. Kudos to Unit Tests (TestAcademy / TestAcademyDispose) for catching these. * Removed debub log. * Back-up commit. * Revert "Back-up commit." This reverts commit f81e835cd314cb14cbc489feb75e430606e0419c. * key changes to wrapper classes made the wrapper classes non-singleton (but internal constructors) made EngineParameters internal * Re-enabled the option to add multiple side channels of the same type * Fixed example env * Add an enum flag to the EnvParamsChannel * Adding .cs.meta files * Update engine config side channel Removed unnecessary accessors Made capture frame rate a parameter * Rename SideChannelUtils —> SideChannelsManager * PR feedback * Minor PR feedback. * Python side changes to the SideChannel redesign (#3826) * Modified the EngineConfig to send one message per field * Created the Python Environment Parameters Channel and hooked it in * Make OnMessageReceived protected * addressing comments * [Side Channels] Edited the documenation and renamed a few things (#3833) * Edited the documetation and renamed a few things * addressing comments * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update com.unity.ml-agents/CHANGELOG.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing unecessary migrating line Co-authored-by: Chris Elion <chris.elion@unity3d.com> * Addressing renaming comments * Removing the EngineParameters class Co-authored-by: Vincent-Pierre BERGES <vincentpierre@unity3d.com> Co-authored-by: Chris Elion <chris.elion@unity3d.com>
2020-04-23 16:46:55 -07:00
channel.set_float_parameter("parameter_1", 2.0)
Develop side channels: migrate reset parameters (#2990) * [WIP] Side Channel initial layout * Working prototype for raw bytes * fixing format mistake * Added some errors and some unit tests in C# * Added the side channel for the Engine Configuration. (#2958) * Added the side channel for the Engine Configuration. Note that this change does not require modifying a lot of files : - Adding a sender in Python - Adding a receiver in C# - subscribe the receiver to the communicator (here is a one liner in the Academy) - Add the side channel to the Python UnityEnvironment (not represented here) Adding the side channel to the environment would look like such : ```python from mlagents.envs.environment import UnityEnvironment from mlagents.envs.side_channel.raw_bytes_channel import RawBytesChannel from mlagents.envs.side_channel.engine_configuration_channel import EngineConfigurationChannel channel0 = RawBytesChannel() channel1 = EngineConfigurationChannel() env = UnityEnvironment(base_port = 5004, side_channels = [channel0, channel1]) ``` * renamings * addressing comments * Logging a message when an unknown side channel number has been received by Unity * Addressing comments * renamings * renamings * Adding FloatProperties to the side channels (#2968) * renaming m_SideChannelsDict to m_SideChannel * renaming and some comments * renaming and adding a GetAndClearReceivedMessages() in the RawBytesSideChannel * micro-optimization * more errors and some nit * addressing comments * Using little-endian format in Python * adding some comments * Code comments * some changes and added the unit tests on both Python and C# * removing default default in get default * Update UnitySDK/Assets/ML-Agents/Scripts/SideChannel/SideChannel.cs Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/side_channel/raw_bytes_channel.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * addressing comments * fixing tests * removing the arguments to reset and the property reset_parameters on the UnityEnvironment * curriculum works but removed the check for reset parameters in the scene * processing side channels before the reset command * Removing engine configuration from C# * Engine configuration removed * fixing the tests * Update ml-agents-envs/mlagents/envs/subprocess_env_manager.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing register callbacks with empty calls in FloarProperties * Clamp instead of min max * removing the brain names from the environment.py print * renaming reset_parameters to get properties * made a default engine config * bug fix * Empty commit * Docs changes for the Side Channels feature (#3011) * Docs changes for the Side Channels feature * replace deprecated with removed on the CustomResetPratmeters` * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update docs/Training-Generalized-Reinforcement-Learning-Agents.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing the console outputs in the docs * Update docs/Training-ML-Agents.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * replace does not work with ignored * adding a note on side channels * adding some steps to migrate * addressing comments * adding more docs to the LL-API * added a blob on how to access the properties in C# * adding space between ResetParameters * fix typo * bug fixes * addressing comments
2019-12-03 16:40:01 -08:00
i = env.reset()
...
```
Once a property has been modified in Python, you can access it in C# after the
next call to `step` as follows:
Develop side channels: migrate reset parameters (#2990) * [WIP] Side Channel initial layout * Working prototype for raw bytes * fixing format mistake * Added some errors and some unit tests in C# * Added the side channel for the Engine Configuration. (#2958) * Added the side channel for the Engine Configuration. Note that this change does not require modifying a lot of files : - Adding a sender in Python - Adding a receiver in C# - subscribe the receiver to the communicator (here is a one liner in the Academy) - Add the side channel to the Python UnityEnvironment (not represented here) Adding the side channel to the environment would look like such : ```python from mlagents.envs.environment import UnityEnvironment from mlagents.envs.side_channel.raw_bytes_channel import RawBytesChannel from mlagents.envs.side_channel.engine_configuration_channel import EngineConfigurationChannel channel0 = RawBytesChannel() channel1 = EngineConfigurationChannel() env = UnityEnvironment(base_port = 5004, side_channels = [channel0, channel1]) ``` * renamings * addressing comments * Logging a message when an unknown side channel number has been received by Unity * Addressing comments * renamings * renamings * Adding FloatProperties to the side channels (#2968) * renaming m_SideChannelsDict to m_SideChannel * renaming and some comments * renaming and adding a GetAndClearReceivedMessages() in the RawBytesSideChannel * micro-optimization * more errors and some nit * addressing comments * Using little-endian format in Python * adding some comments * Code comments * some changes and added the unit tests on both Python and C# * removing default default in get default * Update UnitySDK/Assets/ML-Agents/Scripts/SideChannel/SideChannel.cs Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/side_channel/raw_bytes_channel.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * addressing comments * fixing tests * removing the arguments to reset and the property reset_parameters on the UnityEnvironment * curriculum works but removed the check for reset parameters in the scene * processing side channels before the reset command * Removing engine configuration from C# * Engine configuration removed * fixing the tests * Update ml-agents-envs/mlagents/envs/subprocess_env_manager.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing register callbacks with empty calls in FloarProperties * Clamp instead of min max * removing the brain names from the environment.py print * renaming reset_parameters to get properties * made a default engine config * bug fix * Empty commit * Docs changes for the Side Channels feature (#3011) * Docs changes for the Side Channels feature * replace deprecated with removed on the CustomResetPratmeters` * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update docs/Training-Generalized-Reinforcement-Learning-Agents.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing the console outputs in the docs * Update docs/Training-ML-Agents.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * replace does not work with ignored * adding a note on side channels * adding some steps to migrate * addressing comments * adding more docs to the LL-API * added a blob on how to access the properties in C# * adding space between ResetParameters * fix typo * bug fixes * addressing comments
2019-12-03 16:40:01 -08:00
```csharp
[WIP] Side Channel Design Changes (#3807) * Make EnvironmentParameters a first-class citizen in the API Missing: Python conterparts and testing. * Minor comment fix to Engine Parameters * A second minor fix. * Make EngineConfigChannel Internal and add a singleton/sealed accessor * Make StatsSideChannel Internal and add a singleton/sealed accessor * Changes to SideChannelUtils - Disallow two sidechannels of the same type to be added - Remove GetSideChannels that return a list as that is now unnecessary - Make most methods except (register/unregister) internal to limit users impacting the “system-level” side channels - Add an improved comment to SideChannel.cs * Added Dispose methods to system-level sidechannel wrappers - Specifically to StatsRecorder, EnvironmentParameters and EngineParameters. - Updated Academy.Dispose to take advantage of these. - Updated Editor tests to cover all three “system-level” side channels. Kudos to Unit Tests (TestAcademy / TestAcademyDispose) for catching these. * Removed debub log. * Back-up commit. * Revert "Back-up commit." This reverts commit f81e835cd314cb14cbc489feb75e430606e0419c. * key changes to wrapper classes made the wrapper classes non-singleton (but internal constructors) made EngineParameters internal * Re-enabled the option to add multiple side channels of the same type * Fixed example env * Add an enum flag to the EnvParamsChannel * Adding .cs.meta files * Update engine config side channel Removed unnecessary accessors Made capture frame rate a parameter * Rename SideChannelUtils —> SideChannelsManager * PR feedback * Minor PR feedback. * Python side changes to the SideChannel redesign (#3826) * Modified the EngineConfig to send one message per field * Created the Python Environment Parameters Channel and hooked it in * Make OnMessageReceived protected * addressing comments * [Side Channels] Edited the documenation and renamed a few things (#3833) * Edited the documetation and renamed a few things * addressing comments * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update com.unity.ml-agents/CHANGELOG.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing unecessary migrating line Co-authored-by: Chris Elion <chris.elion@unity3d.com> * Addressing renaming comments * Removing the EngineParameters class Co-authored-by: Vincent-Pierre BERGES <vincentpierre@unity3d.com> Co-authored-by: Chris Elion <chris.elion@unity3d.com>
2020-04-23 16:46:55 -07:00
var envParameters = Academy.Instance.EnvironmentParameters;
float property1 = envParameters.GetWithDefault("parameter_1", 0.0f);
Develop side channels: migrate reset parameters (#2990) * [WIP] Side Channel initial layout * Working prototype for raw bytes * fixing format mistake * Added some errors and some unit tests in C# * Added the side channel for the Engine Configuration. (#2958) * Added the side channel for the Engine Configuration. Note that this change does not require modifying a lot of files : - Adding a sender in Python - Adding a receiver in C# - subscribe the receiver to the communicator (here is a one liner in the Academy) - Add the side channel to the Python UnityEnvironment (not represented here) Adding the side channel to the environment would look like such : ```python from mlagents.envs.environment import UnityEnvironment from mlagents.envs.side_channel.raw_bytes_channel import RawBytesChannel from mlagents.envs.side_channel.engine_configuration_channel import EngineConfigurationChannel channel0 = RawBytesChannel() channel1 = EngineConfigurationChannel() env = UnityEnvironment(base_port = 5004, side_channels = [channel0, channel1]) ``` * renamings * addressing comments * Logging a message when an unknown side channel number has been received by Unity * Addressing comments * renamings * renamings * Adding FloatProperties to the side channels (#2968) * renaming m_SideChannelsDict to m_SideChannel * renaming and some comments * renaming and adding a GetAndClearReceivedMessages() in the RawBytesSideChannel * micro-optimization * more errors and some nit * addressing comments * Using little-endian format in Python * adding some comments * Code comments * some changes and added the unit tests on both Python and C# * removing default default in get default * Update UnitySDK/Assets/ML-Agents/Scripts/SideChannel/SideChannel.cs Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update ml-agents-envs/mlagents/envs/side_channel/raw_bytes_channel.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * addressing comments * fixing tests * removing the arguments to reset and the property reset_parameters on the UnityEnvironment * curriculum works but removed the check for reset parameters in the scene * processing side channels before the reset command * Removing engine configuration from C# * Engine configuration removed * fixing the tests * Update ml-agents-envs/mlagents/envs/subprocess_env_manager.py Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing register callbacks with empty calls in FloarProperties * Clamp instead of min max * removing the brain names from the environment.py print * renaming reset_parameters to get properties * made a default engine config * bug fix * Empty commit * Docs changes for the Side Channels feature (#3011) * Docs changes for the Side Channels feature * replace deprecated with removed on the CustomResetPratmeters` * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update docs/Training-Generalized-Reinforcement-Learning-Agents.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing the console outputs in the docs * Update docs/Training-ML-Agents.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * replace does not work with ignored * adding a note on side channels * adding some steps to migrate * addressing comments * adding more docs to the LL-API * added a blob on how to access the properties in C# * adding space between ResetParameters * fix typo * bug fixes * addressing comments
2019-12-03 16:40:01 -08:00
```
#### Custom side channels
For information on how to make custom side channels for sending additional data
types, see the documentation [here](Custom-SideChannels.md).