Skip to content

Chapter5 - Pong #21

Open
Open

Description

@ma-ra-bu

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?

Activity

  1. walebey commented on Mar 23, 2021

    @walebey

    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'

  2. outlace commented on Mar 23, 2021

    @outlace
    Collaborator

    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.

  3. walebey commented on Mar 23, 2021

    @walebey

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions