Browse Source

render CartPole-v0 env

Fabian Peter Hammerle 3 years ago
parent
commit
de6a8447d8
1 changed files with 24 additions and 0 deletions
  1. 24 0
      test.py

+ 24 - 0
test.py

@@ -0,0 +1,24 @@
+#!/usr/bin/env python3
+
+import time
+
+import gym
+
+
+def _main():
+    env = gym.make("CartPole-v0")
+    env.reset()
+    env.render()
+    while True:
+        action = env.action_space.sample()
+        observation, reward, done, info = env.step(action)
+        env.render()
+        assert not info
+        print(action, observation, reward)
+        if done:
+            break
+    time.sleep(21)
+
+
+if __name__ == "__main__":
+    _main()