test.py 431 B

123456789101112131415161718192021222324
  1. #!/usr/bin/env python3
  2. import time
  3. import gym
  4. def _main():
  5. env = gym.make("CartPole-v0")
  6. env.reset()
  7. env.render()
  8. while True:
  9. action = env.action_space.sample()
  10. observation, reward, done, info = env.step(action)
  11. env.render()
  12. assert not info
  13. print(action, observation, reward)
  14. if done:
  15. break
  16. time.sleep(21)
  17. if __name__ == "__main__":
  18. _main()