opendilab / GoBigger-Challenge-2021

Interested in multi-agents? The 1st Go-Bigger Multi-Agent Decision Intelligence Challenge is coming and a big bonus is waiting for you!
Apache License 2.0
195 stars 33 forks source link

请问一下这个提供的例子是不是不兼容新版本的DI-engine #15

Open atiyit opened 1 year ago

atiyit commented 1 year ago

没有办法复现,提示 Traceback (most recent call last): File "gobigger_selfplay_baseline_main.py", line 15, in from envs import GoBiggerEnv File "..\envs__init.py", line 1, in from .gobigger_env import GoBiggerEnv File "..\envs\gobigger_env.py", line 8, in from ding.envs import BaseEnv, BaseEnvTimestep, BaseEnvInfo ImportError: cannot import name 'BaseEnvInfo' from 'ding.envs' (C:\Users\abc\Anaconda3\envs\qiuqiu\lib\site-packages\ding\envs\init__.py)

注释掉BaseEnvInfo和相关方法会提示 Traceback (most recent call last): File "C:\Users\abc\Anaconda3\envs\qiuqiu\lib\site-packages\ding\envs\env_manager\base_env_manager.py", line 111, in init self._observation_space = self._env_ref.observation_space AttributeError: 'GoBiggerEnv' object has no attribute 'observation_space'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "gobigger_selfplay_baseline_main.py", line 106, in main(main_config) File "gobigger_selfplay_baseline_main.py", line 55, in main env_fn=[lambda: GoBiggerEnv(collector_envcfg) for in range(collector_env_num)], cfg=cfg.env.manager File "C:\Users\abc\Anaconda3\envs\qiuqiu\lib\site-packages\ding\envs\env_manager\subprocess_env_manager.py", line 216, in init super().init(env_fn, cfg) File "C:\Users\abc\Anaconda3\envs\qiuqiu\lib\site-packages\ding\envs\env_manager\base_env_manager.py", line 120, in init self._env_ref.reset() File "..\envs\gobigger_env.py", line 69, in reset self._env = self._launch_game() File "..\envs\gobigger_env.py", line 61, in _launch_game server.start() AttributeError: 'Server' object has no attribute 'start'

jayyoung0802 commented 1 year ago

Hi, thanks to your attention, GoBigger is updating, and new version will come soon! If you want to try this old version, maybe you can try the following: GoBigger: pip install gobigger==0.1.5 DI-engine: (https://github.com/opendilab/DI-engine/releases/tag/v0.2.3)

LYK0520 commented 3 weeks ago

AttributeError: 'GoBiggerEnv' object has no attribute 'observation_space' 我一样遇到这样的问题,请问现在有解决吗

jayyoung0802 commented 3 weeks ago

Hi, add self._observation_space=None, self._action_space=None, self._reward_space=None and the following function in env.

@property
def observation_space(self) -> gym.spaces.Space:
    # The following ensures compatibility with the DI-engine Env class.
    return self._observation_space

@property
def action_space(self) -> gym.spaces.Space:
    # The following ensures compatibility with the DI-engine Env class.
    return self._action_space

@property
def reward_space(self) -> gym.spaces.Space:
    # The following ensures compatibility with the DI-engine Env class.
    return self._reward_space