python版本为
Python 3.6.10 :: Anaconda, Inc.
我成功地按照这份文档进行了操作
但随后我想用PYTHON-API来控制环境,所以我按照这份文档并使用了我的代码
from mlagents_envs.environment import UnityEnvironmentimport mlagents_envsenv = UnityEnvironment(file_name="v1-ball-cube-game.x86_64", base_port=5004, seed=1, side_channels=[])# env = UnityEnvironment(file_name=None, base_port=5004, seed=1,worker_id=0, side_channels=[])print(mlagents_envs.__version__) # outputs 0.16.1print(env.reset()) # outputs Noneprint(env) # outputs <mlagents_envs.environment.UnityEnvironment object at 0x7f3ed001c278>print(str(env.get_agent_groups())) # outputs error
上述代码的输出结果
0.16.1None<mlagents_envs.environment.UnityEnvironment object at 0x7f3ed001c278>Traceback (most recent call last): File "index.py", line 12, in <module> print(str(env.get_agent_groups()))AttributeError: 'UnityEnvironment' object has no attribute 'get_agent_groups'
我确实有这段代码,并且为什么函数get_agent_groups
没有定义?我找不到解决方案。而且它在文档中是写了的
回答:
正如’derHugo’已经提到的,这基本上是一个重复的问题。
您引用的是0.15版本的文档,但使用的是0.16.1版本
env.get_agent_groups()
已被env.get_behavior_names()
替代
这份文档与您的版本相匹配