test_interactive_mode.py 434 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/env python3
  2. import random
  3. import time
  4. import gym
  5. # Load the gym environment
  6. env = gym.make("MiniGrid-Empty-8x8-v0", new_step_api=True)
  7. env.reset()
  8. for i in range(0, 100):
  9. print(f"step {i}")
  10. # Pick a random action
  11. action = random.randint(0, env.action_space.n - 1)
  12. obs, reward, terminated, truncated, info = env.step(action)
  13. env.render()
  14. time.sleep(0.05)
  15. # Test the close method
  16. env.close()