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