openai / retro

Retro Games in Gym
MIT License
3.35k stars 524 forks source link

Observation values all zeroes #248

Open yu263319 opened 2 years ago

yu263319 commented 2 years ago

Issue summary

I wrote a functioning script using gym-retro to play the first five frames of Castevania-Nes (it works) but when I print the ndarray returned by the env.make function ("obs"), it gives me a (224, 240, 3)-shaped ndarray containing all zeroes, even though there is output on the screen. Why does the function not return the pixel information of the screen output? My test script just outputs 5 ndarrays as above containing zeroes? Why?

import retro import sys import numpy as np np.set_printoptions(threshold=sys.maxsize)

def main(): env = retro.make(game='Castlevania-Nes') obs = env.reset()

while True:

for _ in range(5):    
    obs, rew, done, info = env.step(env.action_space.sample())
    print(obs)
    env.render(mode='rgb_array')
#    if done:
#        obs = env.reset()
env.close()

if name == "main": main()

System information

yu263319 commented 2 years ago

Update: The pixel dump works for other games (it gives non-zero data), but not Castlevania. Retro may be hard-coded to look in one place for the screen image, but apparently not all games store this information in the same place.