pythonunity-game-enginemachine-learningreinforcement-learningml-agent

'UnityEnvironment' object has no attribute 'get_agent_groups' ( mlagents_envs 0.16.1 )


python version as

Python 3.6.10 :: Anaconda, Inc.

And was able to follow this docs successfully
But then i want to control environment with PYTHON-API so i followed this and with my code

from mlagents_envs.environment import UnityEnvironment
import mlagents_envs
env = 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.1
print(env.reset()) # outputs None
print(env) # outputs <mlagents_envs.environment.UnityEnvironment object at 0x7f3ed001c278>
print(str(env.get_agent_groups())) # outputs error

Out put of above code

0.16.1
None
<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'

I do have this code and why is function get_agent_groups not defined ? I am unable to find the solution. Plus it is written in docs


Solution

  • Like 'derHugo' already mentioned it is basically a duplicate.

    You're pointing to the documentation of version 0.15 but using version 0.16.1

    env.get_agent_groups() was replaced by env.get_behavior_names()

    This is the documentation that matches your version