ewanlee commited on
Commit
6546740
·
1 Parent(s): 3bac28b

update README for atari ROMs import

Browse files
Files changed (1) hide show
  1. README.md +69 -0
README.md CHANGED
@@ -86,3 +86,72 @@ pip install cython==0.29.37
86
  3. install gym[mujoco]
87
  `pip install gym[mujoco]`
88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  3. install gym[mujoco]
87
  `pip install gym[mujoco]`
88
 
89
+ ### Import Atari ROMs
90
+
91
+ If you encounter the error `Unable to find game "[env_name]"` when running a script for Atari environments, it may be due to the absence of Atari ROMs in the `atari_py` package since version 0.2.7. To resolve this issue, you can manually download the ROMs and add them to Gym's registry.
92
+
93
+ Follow the steps below to import Atari ROMs:
94
+
95
+ #### Step 1: Download ROMs and Install Dependencies
96
+ Create a new Jupyter notebook (e.g., at the root directory of this project) and run the following code cell just once. This code block downloads the ROMs and installs the necessary dependencies (`unrar` and `atari_py`):
97
+
98
+ ```python
99
+ import urllib.request
100
+
101
+ # Download the Atari ROMs
102
+ urllib.request.urlretrieve("http://www.atarimania.com/roms/Roms.rar", "Roms.rar")
103
+
104
+ # Install dependencies
105
+ !pip install unrar
106
+ !pip install atari_py
107
+
108
+ # Extract the ROMs
109
+ !unrar x Roms.rar
110
+
111
+ # Organize and compress ROM folders
112
+ !mkdir rars
113
+ !zip HC\ ROMS.zip HC\ ROMS
114
+ !zip ROMS.zip ROMS
115
+
116
+ # Clean up extracted folders
117
+ !rm -r HC\ ROMS
118
+ !rm -r ROMS
119
+
120
+ # Move zipped ROMS to the rars folder
121
+ !mv HC\ ROMS.zip rars
122
+ !mv ROMS.zip rars
123
+ ```
124
+
125
+ #### Step 2: Import ROMs to Atari-Py
126
+ Now, use the following lines within the same notebook to import the ROMs to `atari_py`:
127
+
128
+ ```python
129
+ # Import ROMs to atari_py
130
+ !python -m atari_py.import_roms rars
131
+
132
+ # Clean up downloaded files and folders
133
+ !rm -r rars
134
+ !rm Roms.rar
135
+ ```
136
+
137
+ #### Step 3: Test the Imported ROMs
138
+ Test the imported ROMs by running the following Python code in your Jupyter notebook:
139
+
140
+ ```python
141
+ import gym
142
+ from atariari.benchmark.wrapper import AtariARIWrapper
143
+
144
+ # Initialize the environment
145
+ env = AtariARIWrapper(gym.make("MsPacmanNoFrameskip-v4"))
146
+ obs = env.reset()
147
+
148
+ # Perform a single step in the environment
149
+ obs, reward, done, info = env.step(1)
150
+
151
+ # Check the information provided by the environment (including labels and scores)
152
+ print(info["labels"])
153
+ ```
154
+
155
+ If everything runs smoothly, you have successfully imported the Atari ROMs and set up your environment.
156
+
157
+ Reference: [StackOverflow answer](https://stackoverflow.com/a/68143504/38626)