Views
No views yet
1from huggingface_hub import hf_hub_download
2import pickle, gymnasium as gym, numpy as np
3
4# Download Q-table
5pkl_path = hf_hub_download(repo_id="berkde/sarsa-lambda-WindyGridworld-v0", filename="q-learning.pkl")
6with open(pkl_path, "rb") as f:
7 model = pickle.load(f)
8
9env = gym.make(
10 model["env_id"],
11 map_name=model.get("map_name"),
12 is_slippery=model.get("slippery", True),
13 render_mode="human",
14)
15
16state, _ = env.reset()
17for _ in range(model["max_steps"]):
18 action = np.argmax(model["qtable"][state])
19 state, reward, terminated, truncated, _ = env.step(action)
20 if terminated or truncated:
21 break
22