Farama-Foundation / MAgent2

An engine for high performance multi-agent environments with very large numbers of agents, along with a set of reference environments
https://magent2.farama.org
MIT License
201 stars 34 forks source link

env.reset() crashed in basic usage example #31

Closed nicklhy closed 9 months ago

nicklhy commented 10 months ago

I installed magent2 with pip install magent2 and copy the missing .py files following this issue. Now I can import magent2 envs in python successfully. But when I tried to run the basic usage example as below. It just crashed.

$ python
Python 3.9.0 (default, Nov 15 2020, 14:28:56) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from magent2.environments import battle_v4
>>> env = battle_v4.env(map_size=16, render_mode='human')
>>> env.reset()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/lhy/.conda/envs/dev/lib/python3.9/site-packages/pettingzoo/utils/wrappers/order_enforcing.py", line 101, in reset
    super().reset(seed=seed, options=options)
  File "/home/lhy/.conda/envs/dev/lib/python3.9/site-packages/pettingzoo/utils/wrappers/base.py", line 99, in reset
    self.env.reset(seed=seed, options=options)
  File "/home/lhy/.conda/envs/dev/lib/python3.9/site-packages/pettingzoo/utils/wrappers/base.py", line 99, in reset
    self.env.reset(seed=seed, options=options)
  File "/home/lhy/.conda/envs/dev/lib/python3.9/site-packages/pettingzoo/utils/conversions.py", line 284, in reset
    self._observations, self.infos = self.env.reset(seed=seed, options=options)
ValueError: too many values to unpack (expected 2)
>>> 

Related lib versions are listed below

$ python -c "import magent2; print(magent2.__version__)"
0.3.2
$ python -c "import pettingzoo; print(pettingzoo.__version__)"
1.23.1
nicklhy commented 10 months ago

After debugging into some source code. I found that magent2/environments/magent_env.py::magent_parallel_env.reset returns a single dict value. This might not be compatible with what pettingzoo expects in the above error msg.

self._observations, self.infos = self.env.reset(seed=seed, options=options)
jonhoye commented 9 months ago

Try: pip uninstall pettingzoo pip install pettingzoo==1.22

nicklhy commented 9 months ago

Try: pip uninstall pettingzoo pip install pettingzoo==1.22

Thanks for your reply. Downgrading pettingzoo to 1.22.0 solves my problem.

Daniel-Huff commented 3 months ago

change dependencies = [ "numpy >=1.21.0", "pygame>=2.1.0", "pettingzoo>=1.22.0", ] worked