Created
August 2, 2022 00:44
-
-
Save liketheflower/2f4bb184ba7f28d54688e1af59b88f7c 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 gym | |
import time | |
import numpy as np | |
import matplotlib.pyplot as plt | |
env = gym.make("MountainCar-v0") | |
env.reset() | |
observations = [] | |
for t in range(1000): | |
# env.render() | |
observation = env.reset() | |
action = env.action_space.sample() | |
observation, reward, done, info = env.step(action) | |
observations.append(observation) | |
if done: | |
print("Episode finished after {} timesteps".format(t + 1)) | |
observations = np.array(observations) | |
plt.scatter(observations[:, 0], observations[:, 1], alpha=0.3) | |
plt.savefig("observations.png") | |
plt.show() | |
env.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment