Reinforcement learning 4 CartPole first step

Let's move CartPole immediately.

CartPole.py


import gym
env = gym.make('CartPole-v0')
for i_episode in range(20):
    observation = env.reset()
    for t in range(100):
        env.render()
        action = env.action_space.sample()
        observation, reward, done, info = env.step(action)
        if done:
            print("Episode finished after {} timesteps".format(t+1))
            break
env.close()
python ./CartPole.py

If it works, it's OK. CartPole seems to be basic and there are many explanations, so ignore the explanations.

Recommended Posts

Reinforcement learning 4 CartPole first step
Reinforcement learning 17 Colaboratory + CartPole + ChainerRL
Reinforcement learning 5 Try programming CartPole?
Reinforcement learning 22 Colaboratory + CartPole + ChainerRL + A3C
Reinforcement learning 24 Colaboratory + CartPole + ChainerRL + ACER
[Introduction] Reinforcement learning
Future reinforcement learning_2
Future reinforcement learning_1
First Deep Learning ~ Struggle ~
Reinforcement learning 1 Python installation
Reinforcement learning 3 OpenAI installation
Reinforcement learning for tic-tac-toe
First Deep Learning ~ Preparation ~
First Deep Learning ~ Solution ~
[Reinforcement learning] Bandit task
Reinforcement learning 1 introductory edition
Reinforcement learning 18 Colaboratory + Acrobat + ChainerRL
Reinforcement learning 7 Learning data log output
Python--The first step in Pygal
Reinforcement learning 28 colaboratory + OpenAI + chainerRL
Reinforcement learning 2 Installation of chainerrl
[Reinforcement learning] Tracking by multi-agent
Reinforcement learning starting with Python
Reinforcement learning 20 Colaboratory + Pendulum + ChainerRL
Reinforcement learning 9 ChainerRL magic remodeling
Reinforcement learning Learn from today
Deep Reinforcement Learning 1 Introduction to Reinforcement Learning
Deep reinforcement learning 2 Implementation of reinforcement learning
DeepMind Reinforcement Learning Framework Acme
Reinforcement learning: Accelerate Value Iteration
Reinforcement learning 21 Colaboratory + Pendulum + ChainerRL + A2C
TF2RL: Reinforcement learning library for TensorFlow2.x
Reinforcement learning 34 Make continuous Agent videos
Reinforcement learning 13 Try Mountain_car with ChainerRL.
Python + Unity Reinforcement learning environment construction
Web scraping with Python First step
[GUI with Python] PyQt5-The first step-
Reinforcement learning 8 Try using Chainer UI
C / C ++ programmer challenges Python (first step)
Deep Reinforcement Learning 3 Practical Edition: Breakout
I tried reinforcement learning using PyBrain
Django admin screen customization first step
The first step in Python Matplotlib
Learn while making! Deep reinforcement learning_1