Comments (3)
I'm getting the same error here with the mismatch in expected values to unpack:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[1], line 11
9 if done:
10 state = env.reset()
---> 11 state, reward, done, info = env.step(env.action_space.sample())
12 env.render()
14 env.close()
File [~/anaconda3/lib/python3.10/site-packages/nes_py/wrappers/joypad_space.py:74](https://untitled+.vscode-resource.vscode-cdn.net/~/anaconda3/lib/python3.10/site-packages/nes_py/wrappers/joypad_space.py:74), in JoypadSpace.step(self, action)
59 """
60 Take a step using the given action.
61
(...)
71
72 """
73 # take the step and record the output
---> 74 return self.env.step(self._action_map[action])
File [~/anaconda3/lib/python3.10/site-packages/gym/wrappers/time_limit.py:50](https://untitled+.vscode-resource.vscode-cdn.net/~/anaconda3/lib/python3.10/site-packages/gym/wrappers/time_limit.py:50), in TimeLimit.step(self, action)
39 def step(self, action):
40 """Steps through the environment and if the number of steps elapsed exceeds ``max_episode_steps`` then truncate.
41
42 Args:
(...)
48
49 """
---> 50 observation, reward, terminated, truncated, info = self.env.step(action)
51 self._elapsed_steps += 1
53 if self._elapsed_steps >= self._max_episode_steps:
ValueError: not enough values to unpack (expected 5, got 4)
from gym-super-mario-bros.
I am dealing with the same issue, it comes from newer gym versions and if you try to use gymnasium. they changed the expected values to include a truncated flag in the step function and an additional dictionary for state in the reset. you will run into the same issue with nes_py as well. I wanted to run an RL model in ray using this library but its about impossible without updating this library to gymnasium. You also need to get a version of nes_py that uses gymnasium which there does seem to be a valid open PR for that update to the nes_py repo that has not been approved yet.
i plan to attempt an update of this library to gymnasium format but python is still newer to me so hopefully someone else beats me to it.
from gym-super-mario-bros.
I did manage to run the environment with gymnasium by doing the following:
import gym
import gym_super_mario_bros
from nes_py.wrappers import JoypadSpace
from gym_super_mario_bros.actions import SIMPLE_MOVEMENT
from gymnasium.wrappers import StepAPICompatibility, TimeLimit
env = gym.make('SuperMarioBros-v0')
steps = env._max_episode_steps # get the original max_episode_steps count
env = JoypadSpace(env.env, SIMPLE_MOVEMENT) # set the joypad wrapper
def gymnasium_reset(self, **kwargs):
return self.env.reset()
# overwrite the old reset to accept `seeds` and `options` args
env.reset = gymnasium_reset.__get__(env, JoypadSpace)
# set TimeLimit back
env = TimeLimit(StepAPICompatibility(env, output_truncation_bool=True), max_episode_steps=steps)
A small explanation:
Gymnasium TimeLimit
wrapper expects 5 arguments in return, so we need to wrap the environment in the StepAPICompatibility
wrapper. So, to continue with the TimeLimit
wrapper, we need to remove it first and wrap with everything that we want, e.g., JoypadSpace
, and then wrap it with the StepAPICompatibility
and finally with the TimeLimit
wrapper.
The JoypadSpace
uses an old version of Gym's reset. So we need to overwrite it to be able to receive extra arguments. A small note, you will not be able to set seeds in have consistent runs across multiple runs with that solution.
from gym-super-mario-bros.
Related Issues (20)
- exception: access violation reading 0x000000000003C208 HOT 3
- Kindly ask how to produce augmented roms? HOT 1
- SuperMarioBros-v3 environment color conflicts HOT 2
- just got many errors at gym_super_mario_bros HOT 1
- x_pos value unexpectedly drops while it shoud be increasing (Mario still moving to the right) HOT 2
- KeyError: 'render_modes' raised by gym_super_mario_bros.make('SuperMarioBros-v0') HOT 4
- Sample screenshot from random state HOT 1
- `unexpected keyword argument 'stages'` when I want to play the game with keyboard HOT 5
- Incorrect number of arguments from call to env.step(action) HOT 5
- Which action can make the little man jump up to the hightest green pip in the first world? HOT 1
- how to get the mario's position in the rended picture HOT 1
- error while trying to install nes-py HOT 1
- osError after updating python
- Why there doesn't have a function that could set Mario to a certain x-position?
- How to play all stages in `SuperMarioBros-v0` but using models trained in separate stages? HOT 1
- CMD code problem
- env has already been closed
- Random (or predefined) Mario initial position in stage
- Can't install this package by pip in ubuntu16 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gym-super-mario-bros.