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

Chapter5 - Pong #21

Open
ma-ra-bu opened this issue Jan 8, 2021 · 3 comments
Open

Chapter5 - Pong #21

ma-ra-bu opened this issue Jan 8, 2021 · 3 comments

Comments

@ma-ra-bu
Copy link

ma-ra-bu commented Jan 8, 2021

The German translation of the book (p. 134) promises:
"However, if you want, you can easily adapt the algorithm to a more difficult game like Pong in OpenAI Gym; you can find such an implementation on the GitHub page for this chapter: http://mng.bz/JzKp."
Unfortunately I couldn't find anything about it! Anyone know where the code is?

Auf Seite 134 im Buch (Hanser) steht:
"Wenn Sie möchten, können Sie den Algorithmus jedoch leicht an ein schwierigeres Spiel wie Pong in OpenAI Gym anpassen; eine solche Implementierung finden Sie auf der GitHub-Seite zu diesem Kapitel: http://mng.bz/JzKp."
Leider habe ich dazu nichts gefunden! Wer weiss, wo der Code ist?

@walebey
Copy link

walebey commented Mar 23, 2021

Look at the comments in all Ch5 notebooks. But that didn´t help me, because the code is not working.
Running the code with pong gives following error message:
....
File "", line 41, in run_episode
raw_state = np.array(worker_env.env.state)
AttributeError: 'AtariEnv' object has no attribute 'state'

@outlace
Copy link
Collaborator

outlace commented Mar 23, 2021

We will try to update the code. I think the OpenAI Gym library has changed since publication and is breaking some of the code unfortunately.

@walebey
Copy link

walebey commented Mar 23, 2021

As of 2020: for Atari environments, you need to use env.env.ale.getScreenRGB() instead to access the state.
But it doesn´t seem to work for both games.

import gym
env = gym.make("CartPole-v1")
env = gym.make("Pong-v0")
observation = env.reset()
print(observation)
print("----------------")
if(type(env.env) is gym.envs.classic_control.cartpole.CartPoleEnv):
print(env.env.state)
else:
print(env.env.ale.getScreenRGB())

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

3 participants