Views
No views yet
1import gymnasium as gym
2from huggingface_hub import hf_hub_download
3import numpy as np
4import pickle
5
6model_file = hf_hub_download(
7 repo_id="Konzai/q-FrozenLake-v1",
8 filename="q-learning.pkl",
9 local_dir="."
10)
11with open("q-learning.pkl", "rb") as f:
12 model = pickle.load(f)
13env = gym.make(
14 "FrozenLake-v1",
15 map_name="4x4",
16 is_slippery=False,
17 render_mode="human"
18)
19n_show_episodes = 3
20max_steps = model["max_steps"]
21q_table = model["q_table"]
22for episode in range(n_show_episodes):
23 state, info = env.reset()
24 for step in range(max_steps):
25 action = np.argmax(q_table[state, :])
26 state, reward, terminated, truncated, info = env.step(action)
27 if terminated or truncated:
28 break