Created
          July 8, 2018 14:04 
        
      - 
      
 - 
        
Save adesgautam/1b298bada0e707acae32ea99fbd4c7ee to your computer and use it in GitHub Desktop.  
    Play FrozenLake leading the Q-table
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | import gym | |
| import numpy as np | |
| import time | |
| import pickle, os | |
| env = gym.make('FrozenLake-v0') | |
| with open("frozenLake_qTable.pkl", 'rb') as f: | |
| Q = pickle.load(f) | |
| def choose_action(state): | |
| action = np.argmax(Q[state, :]) | |
| return action | |
| # start | |
| for episode in range(5): | |
| state = env.reset() | |
| print("*** Episode: ", episode) | |
| t = 0 | |
| while t < 100: | |
| env.render() | |
| action = choose_action(state) | |
| state2, reward, done, info = env.step(action) | |
| state = state2 | |
| if done: | |
| break | |
| time.sleep(0.5) | |
| os.system('clear') | |
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment