Views
No views yet
1Initial board:
2 O O O
3 O O O
4 O O O O O O O
5 O O O . O O O ← Center empty
6 O O O O O O O
7 O O O
8 O O O
9
10Goal:
11 . . .
12 . . .
13 . . . . . . .
14 . . . O . . . ← One peg in center
15 . . . . . . .
16 . . .
17 . . ../mlruns.epsilon = 0.0, yielding a greedy policy. Given fixed weights and the initial board, action selection is deterministic (tie-breaking handled by argmax). If you need multiple trajectories or stochastic solution sampling, you should train or evaluate with a modified script (e.g. softmax over Q-values or ε > 0) — not included in this single-solution release.single-solution and deterministic.1# 1. Install Miniconda (if not already installed)
2# Download from: https://docs.conda.io/en/latest/miniconda.html
3
4# 2. Download model and code from Hugging Face Hub
5hf download emiliodavola/french-solitaire-dqn-single-solution --local-dir ./french-solitaire-model
6cd french-solitaire-model
7
8# 3. Create conda environment from included environment.yml
9conda env create -f environment.yml
10conda activate french-solitaire
11
12# 4. Evaluate model (100 episodes, no rendering)
13python code/eval.py --checkpoint pytorch_model.pt --episodes 100
14
15# 5. With visual rendering (shows all steps)
16python code/eval.py --checkpoint pytorch_model.pt --episodes 1 --rendercode/eval.py will correctly find pytorch_model.pt in the same root directory. The environment.yml file is included in the Hugging Face repo and installs all dependencies automatically (PyTorch with CUDA 12.1, Gymnasium, NumPy, etc.).1# 1. Clone the full repository with all development tools
2git clone https://github.com/emiliodavola/french-solitaire.git
3cd french-solitaire
4
5# 2. Create conda environment from environment.yml (recommended for full dev setup)
6conda env create -f environment.yml
7conda activate french-solitaire
8
9# 3. Download checkpoint from Hugging Face
10hf download emiliodavola/french-solitaire-dqn-single-solution pytorch_model.pt --local-dir ./checkpoints
11
12# 4. Run evaluation with visual rendering (shows all steps)
13python eval.py --checkpoint checkpoints/pytorch_model.pt --episodes 1 --render1import torch
2import numpy as np
3from huggingface_hub import hf_hub_download
4import sys
5from pathlib import Path
6
7# Download model from Hugging Face Hub
8model_path = hf_hub_download(
9 repo_id="emiliodavola/french-solitaire-dqn-single-solution",
10 filename="pytorch_model.pt"
11)
12
13# Download code directory (environment and agent)
14code_dir = Path(model_path).parent / "code"
15if not code_dir.exists():
16 # If code/ doesn't exist, download the full repo
17 from huggingface_hub import snapshot_download
18 repo_path = snapshot_download(repo_id="emiliodavola/french-solitaire-dqn-single-solution")
19 code_dir = Path(repo_path) / "code"
20
21# Add code directory to Python path
22sys.path.insert(0, str(code_dir))
23
24# Import from downloaded code
25from envs.french_solitaire_env import FrenchSolitaireEnv
26from agent.dqn import DQNAgent
27
28# Create environment and agent
29env = FrenchSolitaireEnv()
30agent = DQNAgent(state_dim=49, action_dim=100)
31
32# Load checkpoint
33agent.load(model_path, load_optimizer=False)
34agent.epsilon = 0.0 # Greedy (no exploration)
35
36# Play one episode
37state, info = env.reset()
38done = False
39truncated = False
40
41while not (done or truncated):
42 mask = info.get("action_mask")
43 action = agent.select_action(state, action_mask=mask, training=False)
44 state, reward, done, truncated, info = env.step(action)
45
46print(f"Pegs remaining: {info['pegs_remaining']}")
47print(f"Victory: {info.get('center_win', False)}")| Metric | Value |
|---|---|
| Win rate (1 peg) | 100.0% |
| Center win rate (perfect) | 100.0% |
| Avg. reward per episode | 130.0 |
| Avg. pegs remaining | 1.0 |
| Avg. steps per episode | 31.0 |
1@misc{french-solitaire-dqn-single-solution,
2 author = {Emilio Davola},
3 title = {DQN Agent for French Solitaire - Single-Solution Deterministic Policy},
4 year = {2025},
5 publisher = {Hugging Face},
6 journal = {Hugging Face Hub},
7 howpublished = {\url{https://huggingface.co/emiliodavola/french-solitaire-dqn-single-solution}}
8}