Unity 机器学习代理工具包 (ML-Agents) 是一个开源项目,它使游戏和模拟能够作为训练智能代理的环境。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
Chris Elion 27af58f0 fix release versions and changelog section 3 年前
mlagents_envs fix release versions and changelog section 3 年前
README.md [Release 18] Update versions and links (#5414) 3 年前
pydoc-config.yaml Develop api documentation update (#5325) 3 年前
setup.py Clarify Python 3.8 support (#4784) 4 年前


Unity ML-Agents Python Interface

The mlagents_envs Python package is part of the ML-Agents Toolkit. mlagents_envs provides a Python API that allows direct interaction with the Unity game engine. It is used by the trainer implementation in mlagents as well as the gym-unity package to perform reinforcement learning within Unity. mlagents_envs can be used independently of mlagents for Python communication.


Install the mlagents_envs package with:

python -m pip install mlagents_envs==0.27.0

Usage & More Information

See the Python API Guide for more information on how to use the API to interact with a Unity environment.

For more information on the ML-Agents Toolkit and how to instrument a Unity scene with the ML-Agents SDK, check out the main ML-Agents Toolkit documentation.


  • mlagents_envs uses localhost ports to exchange data between Unity and Python. As such, multiple instances can have their ports collide, leading to errors. Make sure to use a different port if you are using multiple instances of UnityEnvironment.
  • Communication between Unity and the Python UnityEnvironment is not secure.
  • On Linux, ports are not released immediately after the communication closes. As such, you cannot reuse ports right after closing a UnityEnvironment.