openai / retro

Retro Games in Gym
MIT License
3.41k stars 531 forks source link

New Emulator Integration Tutorial #169

Open alexpalms opened 5 years ago

alexpalms commented 5 years ago

Issue summary

I tried to integrate PSX emulator in gym-retro doing the following steps:

Both the gym-retro-integration as well as the simple gym-retro are able to compile successfully, correctly showing also psx emulator. But both of them do not work, showing different, generic errors. Specifically the following one is obtained when executing python3 -m retro.examples.interactive --game GameName Error:

Traceback (most recent call last):
  File "/home/alexpalms/anaconda3/envs/...lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/alexpalms/anaconda3/envs/.../lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/alexpalms/.../aiw-gaming-platform/custom-gym-retro/retro/examples/interactive.py", line 262, in <module>
    main()
  File "/home/alexpalms/.../aiw-gaming-platform/custom-gym-retro/retro/examples/interactive.py", line 257, in main
    ia = RetroInteractive(game=args.game, state=args.state, scenario=args.scenario)
  File "/home/alexpalms/.../aiw-gaming-platform/custom-gym-retro/retro/examples/interactive.py", line 208, in __init__
    env = retro.make(game=game, state=state, scenario=scenario)
  File "/home/alexpalms/../aiw-gaming-platform/custom-gym-retro/retro/__init__.py", line 55, in make
    return RetroEnv(game, state, inttype=inttype, **kwargs)
  File "/home/alexpalms/.../aiw-gaming-platform/custom-gym-retro/retro/retro_env.py", line 87, in __init__
    self.em = retro.RetroEmulator(rom_path)
RuntimeError: Could not load ROM

It would be great to have even a small tutorial on how to add a libretro emulator, or some indications on compatible commits/version of repo that can be found on libretro website.

System information

alexpalms commented 5 years ago

PS: the rom I am using is a cue file where inside are listed 3 bin files (Tekken3)

alexpalms commented 5 years ago

PPS:

System information OS: Mint 19 Python version: 3.6 gym-retro version: 0.7.1

christopherhesse commented 5 years ago

If you build a simple C program that uses the core via the libretro API, are you able to load everything and run the ROM?

alexpalms commented 5 years ago

Hello Christopher,

thanks for your reply. I didn't try it actually. I sense integrating another emulator already present in LibRetro shouldn't be so hard, for this reason I am suggesting adding a small section with a worked case in your docs. It would be of great help.

Maybe this step you are suggesting could also be described there as a preliminary development.

christopherhesse commented 5 years ago

Thanks for writing this guide! I agree it shouldn't be that hard, but definitely if you can't get the core to work without gym-retro, it won't be possible to get it to work with gym-retro.

dota2heqiuzhi commented 1 year ago

Hello Christopher,

thanks for your reply. I didn't try it actually. I sense integrating another emulator already present in LibRetro shouldn't be so hard, for this reason I am suggesting adding a small section with a worked case in your docs. It would be of great help.

Maybe this step you are suggesting could also be described there as a preliminary development.

Did you succeed in trying later? Do you need to modify the source code of gym-retro and then recompile it? I also want to run mame2003-plus-libretro in gym-retro, so I can train the game Double Dragon (Neo-Geo)

MatPoliquin commented 1 year ago

I recently integrated two emulators (Sega 32x and Saturn) into stable-retro (a fork of gym-retro)

I think this PR I made would help with your issues since it enables support for debug logging from within emulator cores. Moreover some cores will crash if they don't have log support (ex mame2003_plus)

https://github.com/Farama-Foundation/stable-retro/pull/48