Professional Documents
Culture Documents
Ass 1
Ass 1
In [1]:
import gym
In [2]:
env = gym.make('MountainCar-v0',render_mode="rgb_array")
In [3]:
# Observation and action space
obs_space = env.observation_space
action_space = env.action_space
print("The observation space: {} ".format(obs_space))
print("The action space: {} ".format(action_space))
In [4]:
In [5]:
import matplotlib.pyplot as plt
In [6]:
env_screen = env.render()
env.close()
<matplotlib.image.AxesImage at 0x266f66029e0>
In [7]:
import time
obs = env.reset()
# Wait a bit before the next frame unless you want to see a crazy fast video
time.sleep(0.001)
plt.imshow(env.render())
# If the epsiode is up, then start another one
if done:
env.reset()