Created
February 3, 2018 07:06
-
-
Save starhopp3r/d4a21c8522ca67da58f1a4376706e079 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import gym | |
# Pong env | |
env = gym.make('Pong-ram-v0') | |
# Reset env | |
env.reset() | |
# Initialize previous obs | |
prev_obs = np.zeros((128,)) | |
# Render and test | |
while True: | |
# Render | |
env.render() | |
# Sample an action from action space [0-5] | |
action = env.action_space.sample() | |
# Take an action | |
observation, reward, done, info = env.step(action) | |
# Difference between previous obs and current obs | |
move = prev_obs - observation | |
# Current obs will become the previous obs | |
prev_obs = observation | |
# Break once done | |
if done: | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment