Guest User

Untitled

a guest
May 21st, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. import gym
  2.  
  3. env = gym.make('CartPole-v1')
  4.  
  5.  
  6.  
  7. highest = 0
  8.  
  9. for e in range(20):
  10. observation = env.reset()
  11. point = 0
  12. print('='*50)
  13. print('episode', e, 'highest', highest)
  14.  
  15. while True:
  16. env.render()
  17.  
  18. action = 1 if observation[2] > 0 else 0
  19. observation, reward, done, info = env.step(action) # take a random action
  20. #print('observation', observation)
  21.  
  22. point += reward
  23. print('point', point)
  24.  
  25. if done:
  26. if point > highest:
  27. highest = point
  28.  
  29. break
Add Comment
Please, Sign In to add comment