test_interactive_mode.py 425 B

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