A Rust CLI tool that analyzes chess games from PGN files and generates comprehensive PDF reports with move-by-move analysis using AI.
- 📖 Parses PGN (Portable Game Notation) files
- 🤖 Uses Ollama's llama3.1:8b model for intelligent move analysis
- ♟️ Generates chessboard diagrams for each position
- 📄 Creates professional LaTeX documents
- 🎯 Automatically compiles to PDF
- 📊 Real-time progress bar showing analysis status
-
Rust (latest stable version)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
-
Ollama with llama3.1:8b model
# Install Ollama from https://ollama.ai ollama pull llama3.1:8b -
LaTeX distribution with xskak package
- macOS:
brew install --cask mactex - Linux:
sudo apt-get install texlive-full - Windows: Install MiKTeX or TeX Live
- macOS:
# Clone the repository
git clone <repository-url>
cd PGNtoChessGameFullAnalysis
# Build the project
cargo build --release# Run with a PGN file
cargo run --release -- sample_game.pgn
# Or use the compiled binary
./target/release/chess-analyzer sample_game.pgnThe tool will:
- Parse the PGN file
- Analyze each move using Ollama
- Generate a LaTeX document with diagrams
- Compile to PDF automatically
Output files will be created in the same directory as the input PGN:
<filename>_analysis.tex- LaTeX source<filename>_analysis.pdf- Final PDF report
cargo run --release -- sample_game.pgnThis will generate:
sample_game_analysis.texsample_game_analysis.pdf
The tool expects standard PGN format with headers:
[Event "Casual Game"]
[Site "?"]
[Date "2024.01.15"]
[White "Fischer, Bobby"]
[Black "Spassky, Boris"]
[Result "1-0"]
1. e4 e5 2. Nf3 Nc6 3. Bb5 ...
The AI analysis includes:
- Strategic ideas behind each move
- Tactical considerations (threats, defenses)
- Positional evaluation
- Alternative move suggestions
Make sure Ollama is running:
ollama serveEnsure you have the required packages:
# Check if pdflatex is available
which pdflatex
# Install missing LaTeX packages if needed
tlmgr install xskak chessboardUpdate dependencies:
cargo update
cargo clean
cargo build --release.
├── Cargo.toml # Rust dependencies
├── src/
│ └── main.rs # Main application code
├── sample_game.pgn # Example PGN file
└── README.md # This file
clap- Command-line argument parsingpgn-reader- PGN file parsingshakmaty- Chess logic and position handlingreqwest- HTTP client for Ollama APIserde- Serialization/deserializationtokio- Async runtimeanyhow- Error handling
Copyright (C) 2026, Shyamal Suhana Chandra
Contributions are welcome! Please feel free to submit a Pull Request.