Q-Learning Agent playing FrozenLake-v1

This is a trained model of a Q-Learning agent playing FrozenLake-v1.

Usage

from huggingface_hub import hf_hub_download
import pickle
import gymnasium as gym
import numpy as np

# Download the model from the Hub
model_path = hf_hub_download(repo_id="Dumoura/q-FrozenLake-v1-4x4-noSlippery", filename="q-learning.pkl")
with open(model_path, "rb") as f:
    model = pickle.load(f)

# Recreate the environment with correct parameters
# Check model['map_name'] and model['slippery'] if they exist
env_kwargs = {}
if "map_name" in model:
    env_kwargs["map_name"] = model["map_name"]
if "slippery" in model:
    env_kwargs["is_slippery"] = model["slippery"]

env = gym.make(model["env_id"], **env_kwargs)

# Load the Q-table
qtable = model["qtable"]

# Test the agent
state, info = env.reset()
done = False
truncated = False
total_reward = 0
while not done and not truncated:
    action = np.argmax(qtable[state, :])
    state, reward, done, truncated, info = env.step(action)
    total_reward += reward
env.close()
print(f"Test episode reward: {total_reward}")
Downloads last month

-

Downloads are not tracked for this model. How to track
Video Preview
loading

Evaluation results

  • mean_reward on FrozenLake-v1-4x4-no_slippery
    self-reported
    0.00 +/- 0.00