Reputation: 41
I am trying to run SuperMarioBros environment in OpenAI baselines. Usually these retro environments are different from native attari 2600 that been support by gym library.
In order to make it run with baselines a third party library is need to be installed that comes with retro using the code taking the help from this link (https://www.videogames.ai/2019/01/29/Setup-OpenAI-baselines-retro.html)
python -m retro.import .
python -m baselines.run --alg=a2c --env=SuperMarioBros-Nes --gamestate=Level3-1.state --network=cnn --num_env=2 --num_timesteps=1e3
but unfortunately even after this, it doesn't run and giving the error of rom not found.
Although after installing the external retro, it should be okay but its requiring raw-rom files directly from game-emulator. Is there any possible way to find a turn around ? Or am I missing something here
Process SpawnProcess-2: Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/retro/__init__.py", line 49, in make retro.data.get_romfile_path(game, inttype)
File "/usr/local/lib/python3.6/dist-packages/retro/data/__init__.py", line 288, in get_romfile_path
raise FileNotFoundError("No romfiles found for game: %s" % game) FileNotFoundError:
No romfiles found for game: SuperMarioBros-Nes
Upvotes: 2
Views: 2387
Reputation: 629
I did a hack and able to run the mario in retro (In windows itself). Below are step by step of the trick:
import retro def main(): env = retro.make(game='SuperMarioBros-Nes') obs = env.reset() while True: obs, rew, done, info = env.step(env.action_space.sample()) env.render() if done: obs = env.reset() env.close() if __name__ == "__main__": main()
An extra tip: If you want to play mario manually after this then run following command. (Z for jump and x for firing): python -m retro.examples.interactive --game SuperMarioBros-Nes
[Enjoy]
Upvotes: 1
Reputation: 629
By default only 1 game ROM is installed by retro.
Did you try this. It is not using retro env (Or maybe using internally, not sure). But it is working for me:
https://pypi.org/project/gym-super-mario-bros/
Python 2.7.16 |Anaconda, Inc.| (default, Mar 14 2019, 21:00:58)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from nes_py.wrappers import BinarySpaceToDiscreteSpaceEnv
>>> import gym_super_mario_bros
>>> from gym_super_mario_bros.actions import SIMPLE_MOVEMENT
>>> env = gym_super_mario_bros.make('SuperMarioBros-v0')
>>> env = BinarySpaceToDiscreteSpaceEnv(env, SIMPLE_MOVEMENT)
>>> done = True
>>> for step in range(5000):
... if done:
... state = env.reset()
... state, reward, done, info = env.step(env.action_space.sample())
... env.render()
...
Note: I am running on linux machine (Windows was giving trouble)
Upvotes: 0