The previous blog introduced OpenAI Gym, OpenAI Gym and intensive learning as well as OpenAI Gym installation, and then run a demo to experience OpenAI Gym this platform to Cartpole (inverted pendulum) as an example, in the working directory to create a Python module , the code is as follows:
Import Gym
env = gym.make (' cartpole-v0 ')
Env.reset () for
_ in range (1000):
env.render ()
Env.step (Env.action_space.sample ()) # Take a random action
where Env.reset () resets the state of the Environment, Env.render () redraw a frame of the environment
The result of animation shows that the stochastic control algorithm is divergent and the system loses stability quickly. If you want to see other environments, try replacing the above cartpole-v0 with Mountaincar-v0,mspacman-v0 (which requires a Atari dependency) or HOPPER-V1 (requiring Mujoco dependencies), all from the Env base class.