Downloads · 30 days
0
Songyao86/blackjack-qlearning-agent
blackjack-qlearning-agent is a reinforcement learning model from Songyao86. Use it for the reinforcement learning task on the model card, and read the license before you ship it in a product. It is set up for reinforcement-learning.
- Environment ID: Blackjack-v1 - Training Episodes: 10000 - Max Steps per Episode: 99 - Learning Rate: 0.7 - Gamma (Discount Factor): 0.95
Downloads · 30 days
0
Access
Public
Updated Jun 16, 2025
Repo size
11.7 KB
Likes
0
Public
Click a slice to open those files.
.mp420.8 KB · 58%
From the Hugging Face model README
Blackjack-v1from huggingface_hub import hf_hub_download
import pickle
import gymnasium as gym
import numpy as np
# 请将下面的占位符替换为你的实际仓库信息
repo_id = "YOUR_USERNAME/YOUR_REPO_NAME" # 替换为你的仓库
filename = "q-learning.pkl"
# 加载模型
model_path = hf_hub_download(repo_id=repo_id, filename=filename)
with open(model_path, "rb") as f:
model = pickle.load(f)
# 重建环境
env = gym.make(
model["env_id"],
render_mode="rgb_array",
**model.get("env_config", {})
)
# 使用Q表进行推理
qtable = model["qtable"]
# 简单的推理示例
state = env.reset()
terminated = False
while not terminated:
# 状态转换为索引
if isinstance(state, tuple):
state_idx = model.get("state_to_index", lambda s: s)(state)
else:
state_idx = state
action = np.argmax(qtable[state_idx])
state, reward, terminated, truncated, _ = env.step(action)