Skip to content
GrozbyPublic

About

๐ŸŽฒ Deep Reinforcement Learning (PPO) agent for Yatzy with an interactive Web GUI and real-time AI move suggestions.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

22 Commits

Folders and files

Repository files navigation

title Yatzy AI Studio
emoji ๐ŸŽฒ
colorFrom blue
colorTo green
sdk gradio
python_version 3.12
app_file app.py
pinned false
license mit
short_description Deep RL agent & interactive Web GUI for Yatzy
tags
reinforcement-learning
ppo
pytorch
fastapi
game-ai

๐ŸŽฒ Yatzy AI Studio

Hugging Face Spaces License: MIT Python 3.10+

๐Ÿš€ Live Demo: Try the trained AI agent live in your browser on Hugging Face Spaces (Grozby/yatzy)!

A Deep Reinforcement Learning (PPO) agent for Yatzy with an interactive Web GUI and real-time AI assistant.


๐ŸŒŸ Overview

This project implements a complete Yatzy game environment, a Proximal Policy Optimization (PPO) reinforcement learning agent, and an interactive Web GUI for human-AI play and agent visualization.

Key Features

  • ๐ŸŽฎ Interactive Web GUI: 3D styled dice, interactive scorecard, roll animations, and synthesized sound effects.
  • ๐Ÿ’ก Real-Time AI Suggestions: Keep probabilities on dice, category ranking badges, and expected score estimations from the PPO Critic value head.
  • ๐Ÿค– Autonomous Agent Mode: Watch the model play full 15-turn games end-to-end with adjustable speeds (Slow to Turbo) or advance step-by-step.
  • ๐Ÿ”„ Checkpoint Discovery: Auto-detects and switches between training checkpoints on the fly.

๐Ÿš€ Quickstart

1. Install Dependencies

Using uv (recommended) or pip:

uv sync
# or
pip install -e .

2. Launch the Web GUI

uv run python run_gui.py

Open http://localhost:8000 in your browser.


๐Ÿง  Training the Agent

To train the PPO model from scratch or resume training:

uv run python -m src.training.train_ppo

Training runs and checkpoints are automatically saved to experiments/run_<timestamp>/.

To run quick evaluation episodes:

uv run python -m src.training.run_episodes

๐Ÿ“ Project Structure

โ”œโ”€โ”€ run_gui.py              # Web GUI launcher script
โ”œโ”€โ”€ ppo_yatzy.pt            # Pre-trained baseline model weights
โ”œโ”€โ”€ pyproject.toml          # Project configuration and dependencies
โ”œโ”€โ”€ experiments/            # Training runs, checkpoints, and metrics
โ””โ”€โ”€ src/
    โ”œโ”€โ”€ game/               # Game rules, scoring logic, and Gymnasium environment
    โ”‚   โ”œโ”€โ”€ environment.py  # YatzyEnvironment with observation and action spaces
    โ”‚   โ”œโ”€โ”€ scoring.py      # Category evaluation rules (Upper section, Yatzy, etc.)
    โ”‚   โ””โ”€โ”€ state.py        # Game state snapshot utilities
    โ”œโ”€โ”€ training/           # RL algorithm implementation
    โ”‚   โ”œโ”€โ”€ agent.py        # PPO Agent logic & action selection
    โ”‚   โ”œโ”€โ”€ ppo_network.py  # Actor-Critic neural network architecture
    โ”‚   โ”œโ”€โ”€ buffer.py       # Rollout experience buffer
    โ”‚   โ””โ”€โ”€ train_ppo.py    # Training loop with Hydra configuration
    โ””โ”€โ”€ gui/                # Web application backend and frontend
        โ”œโ”€โ”€ server.py       # FastAPI application endpoints
        โ”œโ”€โ”€ service.py      # Game session management & model analysis engine
        โ””โ”€โ”€ static/         # Web UI assets (HTML, CSS, JS)

โŒจ๏ธ Controls & Shortcuts

Action Shortcut
Roll Dice / Apply AI Move Space
Toggle Dice 1 โ€“ 5 1, 2, 3, 4, 5
Toggle Auto Play A
New Game N

About

๐ŸŽฒ Deep Reinforcement Learning (PPO) agent for Yatzy with an interactive Web GUI and real-time AI move suggestions.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages