Skip to content

Instantly share code, notes, and snippets.

@adesgautam
Created July 8, 2018 14:04
Show Gist options
  • Save adesgautam/1b298bada0e707acae32ea99fbd4c7ee to your computer and use it in GitHub Desktop.
Save adesgautam/1b298bada0e707acae32ea99fbd4c7ee to your computer and use it in GitHub Desktop.
Play FrozenLake leading the Q-table
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