Skip to content

Sapana-Micro-Software/pgn2chessanalysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chess Analyzer

A Rust CLI tool that analyzes chess games from PGN files and generates comprehensive PDF reports with move-by-move analysis using AI.

Features

  • 📖 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

Prerequisites

  1. Rust (latest stable version)

    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  2. Ollama with llama3.1:8b model

    # Install Ollama from https://ollama.ai
    ollama pull llama3.1:8b
  3. LaTeX distribution with xskak package

    • macOS: brew install --cask mactex
    • Linux: sudo apt-get install texlive-full
    • Windows: Install MiKTeX or TeX Live

Installation

# Clone the repository
git clone <repository-url>
cd PGNtoChessGameFullAnalysis

# Build the project
cargo build --release

Usage

# Run with a PGN file
cargo run --release -- sample_game.pgn

# Or use the compiled binary
./target/release/chess-analyzer sample_game.pgn

The tool will:

  1. Parse the PGN file
  2. Analyze each move using Ollama
  3. Generate a LaTeX document with diagrams
  4. 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

Example

cargo run --release -- sample_game.pgn

This will generate:

  • sample_game_analysis.tex
  • sample_game_analysis.pdf

PGN Format

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 ...

Analysis Features

The AI analysis includes:

  • Strategic ideas behind each move
  • Tactical considerations (threats, defenses)
  • Positional evaluation
  • Alternative move suggestions

Troubleshooting

Ollama Connection Error

Make sure Ollama is running:

ollama serve

LaTeX Compilation Error

Ensure you have the required packages:

# Check if pdflatex is available
which pdflatex

# Install missing LaTeX packages if needed
tlmgr install xskak chessboard

Build Errors

Update dependencies:

cargo update
cargo clean
cargo build --release

Project Structure

.
├── Cargo.toml          # Rust dependencies
├── src/
│   └── main.rs         # Main application code
├── sample_game.pgn     # Example PGN file
└── README.md           # This file

Dependencies

  • clap - Command-line argument parsing
  • pgn-reader - PGN file parsing
  • shakmaty - Chess logic and position handling
  • reqwest - HTTP client for Ollama API
  • serde - Serialization/deserialization
  • tokio - Async runtime
  • anyhow - Error handling

License

Copyright (C) 2026, Shyamal Suhana Chandra

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

PGN to chess game full analysis

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages