openai / retro

Retro Games in Gym
MIT License
3.39k stars 526 forks source link

Issue with GB, GBC, and GBA roms #221

Closed prabhatnagarajan closed 3 years ago

prabhatnagarajan commented 3 years ago

Issue summary

When I run this code:

import retro
import os

SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))

def main():
        retro.data.Integrations.add_custom_path(
                os.path.join(SCRIPT_DIR, "custom_integrations")
        )
        assert "PokemonRedGB" in retro.data.list_games(inttype=retro.data.Integrations.ALL)
        pokemon_red_hash = 'ea9bcae617fdf159b045185467ae58b2e4a48b9a'
        known_hashes = retro.data.get_known_hashes()
        game, ext, directory = known_hashes[pokemon_red_hash]
        print("Game: " + str(game))
        print("Extension: " + str(ext))
        print("Directory: " + str(directory))
        env = retro.make("PokemonRedGB")

if __name__ == "__main__":
        main()

I get this output: Game: PokemonRedGB Extension: .pce

Directory: /Users/prabhat/pokemon_ai/custom_integrations
Traceback (most recent call last):
  File "main.py", line 21, in <module>
    main()
  File "main.py", line 17, in main
    env = retro.make("PokemonRedGB")
  File "/Users/prabhat/miniconda3/envs/pokemon_ai/lib/python3.7/site-packages/retro/__init__.py", line 49, in make
    retro.data.get_romfile_path(game, inttype)
  File "/Users/prabhat/miniconda3/envs/pokemon_ai/lib/python3.7/site-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: PokemonRedGB

It seems my extension is being processed as PCE. Is there something I'm missing?

Inside /Users/prabhat/pokemon_ai/custom_integrations/PokemonRedGB, I have:

PokemonRed.start.state  data.json       metadata.json       rom.gb      rom.sha         scenario.json

I produced the start state using the UI (and I can load it). My metadata.json has:

{
  "default_state": "PokemonRed.start"
}

My data.json and scenario.json are just empty braces. I'm trying to get the game environment to load before setting the data/scenario variables.

System information

Any help is appreciated.

christopherhesse commented 3 years ago

Does it work if you rename the folder to PokemonRed-GameBoy? Seems like something is off with the extension detection stuff.

prabhatnagarajan commented 3 years ago

Thanks! that solved the extension issue at least. I'm not sure if this is written somewhere, but it might be helpful to write down somewhere that custom integrations should be named according to the keys listed in these files:

https://github.com/openai/retro/tree/71241e73c9cbdb7cc0a842f324ec437a81ebb359/cores

E.g. https://github.com/openai/retro/blob/master/cores/gb.json#L2 indicates that the extensions should be Gameboy. I think the full list is:

christopherhesse commented 3 years ago

If you want to add that to the docs, I would definitely merge that PR.

prabhatnagarajan commented 3 years ago

PR here: https://github.com/openai/retro/pull/223. I haven't rendered the built docs, though.