Last active
August 18, 2018 08:37
-
-
Save araffin/9a5be160b42a24bfd3e33ba9621b5e7c to your computer and use it in GitHub Desktop.
This file contains 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 imageio | |
import numpy as np | |
from stable_baselines.common.policies import MlpPolicy | |
from stable_baselines import A2C | |
model = A2C(MlpPolicy, "LunarLander-v2").learn(100000) | |
images = [] | |
obs = model.env.reset() | |
img = model.env.render(mode='rgb_array') | |
for i in range(350): | |
images.append(img) | |
action, _ = model.predict(obs) | |
obs, _, _ ,_ = model.env.step(action) | |
img = model.env.render(mode='rgb_array') | |
imageio.mimsave('lander_a2c.gif', [np.array(img[0]) for i, img in enumerate(images) if i%2 == 0], fps=29) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment