Errors with Atari Environments in PettingZooML

171 views Asked by At

I'm trying to get the Atari environments from Petting Zoo working: https://www.pettingzoo.ml/. I've installed the AutoROMs and I can see the multiple .bin files from all the environments in the directory where the ROMs are installed. However, when I run the following code

import gym, supersuit
from pettingzoo.atari import boxing_v2

path = '/home/myname/miniconda/envs/gym/lib/python3.8/site-packages/multi_agent_ale_py/roms'
env = boxing_v2.env(obs_type='rgb_image', full_action_space=True, max_cycles=100000, auto_rom_install_path=path)

I get the following error:

Traceback (most recent call last):
  File "testingboxingpettingzoo.py", line 5, in <module>
    env = boxing_v2.env(obs_type="rgb_image", full_action_space=True, max_cycles=100000, auto_rom_install_path=path)
  File "/home/myname/miniconda3/envs/gym/lib/python3.8/site-packages/pettingzoo/atari/base_atari_env.py", line 19, in env_fn
    env = raw_env_fn(**kwargs)
  File "/home/myname/miniconda3/envs/gym/lib/python3.8/site-packages/pettingzoo/atari/boxing/boxing.py", line 10, in raw_env
    version_num = parent_file[0].split("_")[-1].split(".")[0]
IndexError: list index out of range

I'm following everything in the documentation so not sure what I'm missing here.

1

There are 1 answers

3
Rob Heiser On BEST ANSWER

It looks like a bug in the package's code. Given the pathname of /home/myname/miniconda3/envs/gym/lib/python3.8/site-packages/pettingzoo/atari/boxing/boxing.py

I'll comment the code inline based on what I see in the package's repository.

def raw_env(**kwargs):
    name = os.path.basename(__file__).split(".")[0] 
    # name = "/home/myname/miniconda3/envs/gym/lib/python3"

    parent_file = glob(
        os.path.join(os.path.dirname(os.path.dirname(__file__)), name + "*.py")
    )
    # parent_file = []

    version_num = parent_file[0].split("_")[-1].split(".")[0]
    # IndexError is raised because there is no element 0 in parent_file

    name = name + "_" + version_num
    return BaseAtariEnv(
        game="boxing", num_players=2, mode_num=None, env_name=name, **kwargs
    )

It looks like the package may have never been tested while installed on a path that has a '.' in it.