最近学习MADDPG算法,用MPE环境来测试算法性能。于是便下载了pettingzoo包,运行了simple_tag_v3环境,此环境中有猎人、逃亡者和障碍物。
问题1: MPE中的simple_tag_v3环境,在渲染时看似移动的问题
由于相机视角跟随导致的视觉错觉。这个问题在 GitHub 的 PettingZoo Issue #1255 中有详细讨论,算是一个bug,在MPE2中已经修复了此问题。解决此问题的办法有两种:
(1)安装MPE2;
(2)修改MPE的内核代码,修改simply_env.py和simple_tag.py(参考Link),然后在main函数的env初始化时env =simple_tag_v3.parallel_env(render_mode="human", max_cycles = args.max_cycles, continuous_actions=True, dynamic_rescaling=True)加上标红的参数。
注:MPE2环境要求python>=3.8
问题2: 使用max_cycle=25,程序不会在执行25次时自动结束开始下一次循环,而是报错,我觉得这可能是老版的bug,解决办法:
将源码../py370/lib/python3.7/site-packages/supersuit/utils/base_aec_wrapper.py中43行的
if not self.terminations[agent] or self.truncations[agent]:
修改为:
if not self.terminations[agent] and not self.truncations[agent]:
然后main函数中的
next_obs, rewards, terminations, truncations, infos = env.step(action_dict)
返回的truncation=True表示本轮运行结束,就可以开始下一个episode运行了。