Skip to content

Instantly share code, notes, and snippets.

@taotao54321
Created November 7, 2016 16:20
Show Gist options
  • Save taotao54321/1d728e72fb634efeccc913dd37d8e859 to your computer and use it in GitHub Desktop.
Save taotao54321/1d728e72fb634efeccc913dd37d8e859 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import gym
def get_action():
while True:
try:
act = int(input("--- direction(0:L, 1:D, 2:R, 3:U) > "))
return act
except ValueError:
pass
def main():
env = gym.make("FrozenLake-v0")
while True:
ob = env.reset()
env.render()
while True:
ob, reward, done, info = env.step(get_action())
print()
env.render()
print("Observation: {}".format(ob))
print("Reward: {}".format(reward))
print("Info: {}".format(info))
print()
if done:
print("========== D O N E ==========")
print()
break
if __name__ == "__main__": main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment