Reinforcement learning 5 Try programming CartPole?

It is assumed that reinforcement learning 4 has been completed.

Let's do some simple programming.

CartPole2.py


import gym
env = gym.make('CartPole-v0')
for i in range(20):
    observation = env.reset()
    for t in range(100):
        env.render()
        action = 0
        if observation[2]>0:
            action = 1
        observation, reward, done, info = env.step(action)
        if done:
            print("Episode{} finished after {} timesteps".format(i, t+1))
            break
env.close()

CartPole.py was moving randomly. The difference from CartPole.py is that you want to change the action due to the difference in observation. It becomes feedback control.

Recommended Posts

Reinforcement learning 5 Try programming CartPole?
Reinforcement learning 17 Colaboratory + CartPole + ChainerRL
Reinforcement learning 4 CartPole first step
Reinforcement learning 13 Try Mountain_car with ChainerRL.
Reinforcement learning 22 Colaboratory + CartPole + ChainerRL + A3C
Reinforcement learning 8 Try using Chainer UI
Reinforcement learning 24 Colaboratory + CartPole + ChainerRL + ACER
Reinforcement learning 3 Dynamic programming / TD method
[Introduction] Reinforcement learning
Future reinforcement learning_2
Future reinforcement learning_1
Try OpenAI's standard reinforcement learning algorithm PPO
Reinforcement learning 11 Try OpenAI acrobot with ChainerRL.
Reinforcement learning 10 Try using a trained neural network.
Reinforcement learning 1 Python installation
Reinforcement learning 3 OpenAI installation
Reinforcement learning for tic-tac-toe
[Reinforcement learning] Bandit task
Python + Unity Reinforcement Learning (Learning)
Reinforcement learning 1 introductory edition
Reinforcement learning 18 Colaboratory + Acrobat + ChainerRL
Try deep learning with TensorFlow
Reinforcement learning 7 Learning data log output
Play with reinforcement learning with MuZero
Deep Learning Gaiden ~ GPU Programming ~
Try normal Linux programming Part 7
Reinforcement learning 28 colaboratory + OpenAI + chainerRL
Try programming with a shell!
Try GUI programming with Hy
Reinforcement learning 19 Colaboratory + Mountain_car + ChainerRL
Reinforcement learning 2 Installation of chainerrl
[Reinforcement learning] Tracking by multi-agent
Reinforcement learning 6 First Chainer RL
Try normal Linux programming Part 2
Reinforcement learning starting with Python
Reinforcement learning 20 Colaboratory + Pendulum + ChainerRL
Try Deep Learning with FPGA
Reinforcement learning 9 ChainerRL magic remodeling
Reinforcement learning Learn from today
Try normal Linux programming Part 4
Python Machine Learning Programming> Keywords
Try normal Linux programming Part 6
[Introduction to Reinforcement Learning] Reinforcement learning to try moving for the time being
Deep Reinforcement Learning 1 Introduction to Reinforcement Learning
1st month of programming learning
Try Q-learning in Dragon Quest-style battle [Introduction to Reinforcement Learning]
Try machine learning with Kaggle
Deep reinforcement learning 2 Implementation of reinforcement learning
DeepMind Reinforcement Learning Framework Acme
Reinforcement learning: Accelerate Value Iteration
Try to make a blackjack strategy by reinforcement learning ((1) Implementation of blackjack)
Reinforcement learning 21 Colaboratory + Pendulum + ChainerRL + A2C
Try Deep Learning with FPGA-Select Cucumbers
TF2RL: Reinforcement learning library for TensorFlow2.x
Python + Unity Reinforcement learning environment construction
Try deep learning with TensorFlow Part 2
Machine learning beginners try linear regression
Explore the maze with reinforcement learning
Try machine learning with scikit-learn SVM
[Machine learning] Try studying random forest
Deep Reinforcement Learning 3 Practical Edition: Breakout