Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to receive both images and RAM states with the new API? #440

Closed
danijar opened this issue Nov 19, 2021 · 2 comments
Closed

How to receive both images and RAM states with the new API? #440

danijar opened this issue Nov 19, 2021 · 2 comments

Comments

@danijar
Copy link

danijar commented Nov 19, 2021

I'm interested in training an agent from the images while also recording the corresponding RAM states for later analysis. Previously, I have been using env._get_ram() for this purpose, but it seems that the method is no longer available. Is there a way to do this with the new API?

import gym

env = gym.make('ALE/Breakout-v5',
    obs_type='rgb',                   # ram | rgb | grayscale    <-- I would like both ram and grayscale
    frameskip=5,                      # frame skip
    mode=0,                           # game mode, see Machado et al. 2018
    difficulty=0,                     # game difficulty, see Machado et al. 2018
    repeat_action_probability=0.25,   # Sticky action probability
    full_action_space=True,           # Use all actions
    render_mode=None                  # None | human | rgb_array
)
@JesseFarebro
Copy link
Collaborator

Hi @danijar,

You'll still be able to get the RAM buffer by calling,

ram = env.ale.getRAM()

# OR if you want something more efficient depending on your circumstances
ram = np.empty((env.ale.getRAMSize(),), dtype=np.uint8)
env.ale.getRAM(ram)

Hope that helps!

@danijar
Copy link
Author

danijar commented Nov 20, 2021

Perfect, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants