Skip to content

Latest commit

ย 

History

History
93 lines (69 loc) ยท 2.52 KB

File metadata and controls

93 lines (69 loc) ยท 2.52 KB

Hangman ML ๐ŸŽฎ

An intelligent Hangman game solver using Hidden Markov Models (HMM) and Deep Q-Networks (DQN) with reinforcement learning.

๏ฟฝ Features

  • Multiple AI Approaches: HMM, DQN, Imitation Learning, and Ensemble methods
  • Interactive GUI: Play against AI or watch AI play automatically
  • Comprehensive Analysis: Detailed performance metrics and visualizations
  • Production Ready: Clean, modular codebase with proper documentation

๐Ÿ“ Project Structure

Hackman-ML/
โ”œโ”€โ”€ src/                    # Source code
โ”‚   โ”œโ”€โ”€ hangman_dqn_model.py   # Core models (HMM, DQN, Environment)
โ”‚   โ”œโ”€โ”€ hangman_gui.py         # Streamlit GUI
โ”‚   โ”œโ”€โ”€ test_model.py          # Model testing
โ”‚   โ”œโ”€โ”€ train_quick_dqn.py     # Quick training (~30 min)
โ”‚   โ””โ”€โ”€ train_improved_dqn.py  # Full training (~2-3 hrs)
โ”œโ”€โ”€ Data/                   # Training and test data
โ”œโ”€โ”€ models/                 # Saved model weights
โ”œโ”€โ”€ Assets/                 # Generated diagrams and plots
โ”œโ”€โ”€ hangman_agent.ipynb    # Main Jupyter notebook
โ””โ”€โ”€ requirements.txt       # Dependencies

๐ŸŽฏ Quick Start

1. Install Dependencies

pip install -r requirements.txt

2. Run the GUI

streamlit run src/hangman_gui.py

3. Train a Model

# Quick training (30 minutes)
python src/train_quick_dqn.py

# Full training (2-3 hours)
python src/train_improved_dqn.py

4. Test a Model

python src/test_model.py

๐Ÿ“Š Results

  • Pure HMM: 31.6% win rate (Best performer!)
  • DQN (trained): 55-65% win rate (after proper training)
  • Imitation Learning: 8.8% win rate
  • Ensemble: 3.75% win rate

See Assets/ folder for detailed visualizations.

๏ฟฝ๏ธ Technologies

  • Python 3.12+
  • PyTorch - Deep learning framework
  • Streamlit - Interactive GUI
  • Matplotlib - Visualizations
  • NumPy & Pandas - Data processing

๐Ÿ“– Documentation

๐ŸŽฎ How to Play

  1. Launch the GUI: streamlit run src/hangman_gui.py
  2. Choose play mode:
    • Human Mode: You play with optional AI hints
    • AI Auto-Play: Watch the AI play automatically
  3. Select difficulty and AI model (HMM or DQN)
  4. Start playing!

๐Ÿ“ License

See LICENSE file for details.

๐Ÿ‘ค Author

Akshay AG - akshayag2005