Created
November 7, 2016 16:20
-
-
Save taotao54321/1d728e72fb634efeccc913dd37d8e859 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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