我正在运行Python3 (3.8.10),并尝试使用gym_super_mario_bros (7.3.0)和nes_py库编写教程。我遵循了各种教程代码,并尝试在多台计算机上,但得到了一个错误。我试图调整一些参数,比如将一个“截断”变量添加到要返回的值列表中。因为这是一个教程级的例子,我很好奇到底出了什么问题。它看起来与env.step()类似。以下是代码:
from nes_py.wrappers import JoypadSpace
from gym_super_mario_bros.actions import SIMPLE_MOVEMENT
env = gym_super_mario_bros.make('SuperMarioBros-v0')
env = JoypadSpace(env, SIMPLE_MOVEMENT)
done = True
for step in range(1000):
if done:
env.reset()
state, reward, done, info = env.step(env.action_space.sample())
env.render()
env.close()
我得到的错误如下:
/home/d/.local/lib/python3.8/site-packages/gym/envs/registration.py:555: UserWarning: WARN: The environment SuperMarioBros-v0 is out of date. You should consider upgrading to version `v3`.
logger.warn(
/home/d/.local/lib/python3.8/site-packages/gym/utils/passive_env_checker.py:195: UserWarning: WARN: The result returned by `env.reset()` was not a tuple of the form `(obs, info)`, where `obs` is a observation and `info` is a dictionary containing additional information. Actual type: `<class 'numpy.ndarray'>`
logger.warn(
/home/d/.local/lib/python3.8/site-packages/gym/utils/passive_env_checker.py:219: DeprecationWarning: WARN: Core environment is written in old step API which returns one bool instead of two. It is recommended to rewrite the environment with new step API.
logger.deprecation(
Traceback (most recent call last):
File "mario.py", line 12, in <module>
state, reward, done, info = env.step(env.action_space.sample())
File "/home/d/.local/lib/python3.8/site-packages/nes_py/wrappers/joypad_space.py", line 74, in step
return self.env.step(self._action_map[action])
File "/home/d/.local/lib/python3.8/site-packages/gym/wrappers/time_limit.py", line 50, in step
observation, reward, terminated, truncated, info = self.env.step(action)
ValueError: not enough values to unpack (expected 5, got 4)
非常感谢您的指导,谢谢!
发布于 2022-10-14 05:35:46
移至"...../python3.8/site-packages/gym/wrappers/time_limit.py".And删除所有“截断”
https://stackoverflow.com/questions/74060371
复制相似问题