Skip to main content

A professional chess post-game analysis tool with CLI and web interfaces

Project description

โ™Ÿ๏ธ Chess Post-Game Analyst

Chess Analyst Banner

Python Version License: MIT Code Style: Black PRs Welcome

A professional, production-ready chess game analysis tool with interactive web interface

Try Live Demo ๐Ÿ“š Documentation

Interactive Analysis Evaluation Graph Coaching Tips

Features โ€ข Quick Start โ€ข Installation โ€ข Documentation โ€ข Contributing


๐ŸŽฏ Features

Core Analysis

  • โœจ Deep Game Analysis - Powered by Stockfish engine for accurate position evaluation
  • ๐ŸŽฏ Move Classification - Identifies brilliant moves, blunders, mistakes, and inaccuracies
  • ๐Ÿ“Š Accuracy Metrics - Calculate player accuracy and performance ratings
  • ๐Ÿ” Critical Moments - Highlight turning points and missed opportunities
  • ๐Ÿ“ PGN Support - Parse and analyze standard PGN (Portable Game Notation) files

Interactive Web Interface

  • โ™Ÿ๏ธ Interactive Chessboard - Replay games move-by-move with visual position display
  • ๐Ÿ“ˆ Evaluation Graph - See position evaluation change throughout the game
  • ๐Ÿง  Coaching Tips - Get beginner-friendly explanations for every type of mistake
  • ๐Ÿ“‹ Paste PGN - Analyze games directly from clipboard without file upload
  • โญ Sample Games - Try analysis with pre-loaded famous games
  • โŒจ๏ธ Keyboard Controls - Navigate with arrow keys for quick replay
  • ๐Ÿ“ฑ Responsive Design - Works seamlessly on desktop, tablet, and mobile

Output Formats

  • ๐Ÿ“„ JSON - Machine-readable format for integration
  • ๐Ÿ“ Text - Human-readable analysis reports
  • ๐ŸŒ HTML - Rich formatted reports with diagrams
  • ๐Ÿ“Š Statistics - Detailed game statistics and insights

Production Features

  • ๐Ÿณ Docker Support - Easy deployment with Docker and docker-compose
  • โšก Fast Performance - Optimized for analyzing multiple games
  • ๐Ÿ”’ Error Handling - Robust error handling and logging
  • โœ… Well Tested - Comprehensive unit and integration tests
  • ๐Ÿ“š Documentation - Complete API and usage documentation

๐Ÿš€ Quick Start for Beginners

Never analyzed a chess game before? No problem! Here's how to get started in 3 minutes:

  1. Play a game on Chess.com or Lichess

  2. Export your game as a PGN file:

    • On Chess.com: Archive โ†’ Click game โ†’ Share โ†’ Download PGN
    • On Lichess: Click game โ†’ Export โ†’ Download PGN
  3. Visit Chess Analyst and upload your file

  4. Review your analysis - see your mistakes, accuracy, and get tips to improve!

Or try instantly: Click "Try Sample" to analyze a famous game without uploading anything!

๐Ÿ“š New to chess analysis? Read our Complete Beginner's Guide


๐Ÿš€ Installation

Prerequisites

Quick Install

# Clone the repository
git clone https://github.com/lekhanpro/chess-post-game-analyst.git
cd chess-post-game-analyst

# Install dependencies
pip install -r requirements.txt

# Install the package
pip install -e .

Docker Installation

# Build and run with Docker Compose
docker-compose up -d

# Access web interface at http://localhost:5000

๐Ÿ’ก Usage

Command Line Interface

Basic Analysis

# Analyze a single PGN file
chess-analyst analyze game.pgn

# Specify output format
chess-analyst analyze game.pgn --format json

# Save analysis to file
chess-analyst analyze game.pgn --output analysis.txt

Advanced Options

# Analyze with custom engine depth
chess-analyst analyze game.pgn --depth 20

# Show only blunders and mistakes
chess-analyst analyze game.pgn --threshold mistake

# Analyze multiple games
chess-analyst analyze games/*.pgn --output results/

Configuration

# Set Stockfish engine path
chess-analyst config --engine-path /usr/local/bin/stockfish

# View current configuration
chess-analyst config --show

Web Interface

# Start the web server
python web/app.py

# Or use the CLI command
chess-analyst serve --port 5000

Then open your browser to http://localhost:5000

Python API

from chess_analyst import GameAnalyzer, PGNParser

# Load a game
parser = PGNParser("game.pgn")
game = parser.load_game()

# Analyze the game
analyzer = GameAnalyzer(engine_path="/usr/local/bin/stockfish")
analysis = analyzer.analyze(game)

# Get results
for move_analysis in analysis.moves:
    print(f"Move {move_analysis.move_number}: {move_analysis.classification}")
    print(f"Evaluation: {move_analysis.evaluation}")

๐Ÿ“Š Sample Output

CLI Output

โ™Ÿ๏ธ  Chess Game Analysis Report
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

Game Information:
  White: Magnus Carlsen (2863)
  Black: Hikaru Nakamura (2829)
  Event: World Blitz Championship 2024
  Result: 1-0

Overall Statistics:
  White Accuracy: 94.2%
  Black Accuracy: 87.6%
  Total Moves: 42
  Critical Positions: 5

Move Analysis:
  โœจ Brilliant Moves: 2
  โœ… Good Moves: 35
  โš ๏ธ  Inaccuracies: 3
  โŒ Mistakes: 1
  ๐Ÿ’ฅ Blunders: 1

Key Moments:
  Move 18: Black missed winning continuation (-3.2 โ†’ +0.5)
  Move 24: White found brilliant tactical shot (+0.8 โ†’ +4.1)
  Move 31: Black blunder lost the game (+2.1 โ†’ +8.4)

๐Ÿ› ๏ธ Development

Setup Development Environment

# Install development dependencies
pip install -r requirements-dev.txt

# Install pre-commit hooks
pre-commit install

Running Tests

# Run all tests
pytest tests/ -v

# Run with coverage
pytest tests/ --cov=chess_analyst --cov-report=html

# Run specific test file
pytest tests/test_analyzer.py

Code Quality

# Format code
black chess_analyst/

# Lint code
flake8 chess_analyst/

# Type checking
mypy chess_analyst/

๐Ÿ“š Documentation


๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

Quick Start for Contributors

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ™ Acknowledgments

  • python-chess - Chess library for Python
  • Stockfish - Powerful chess engine
  • chessboard.js - JavaScript chessboard component
  • The chess community for continuous inspiration

๐Ÿ“ง Contact

Project Maintainer: @lekhanpro

Project Link: https://github.com/lekhanpro/chess-post-game-analyst


Made with โ™Ÿ๏ธ by chess enthusiasts, for chess enthusiasts

โญ Star this repository if you find it helpful!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chess_post_analyst-1.0.0.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chess_post_analyst-1.0.0-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file chess_post_analyst-1.0.0.tar.gz.

File metadata

  • Download URL: chess_post_analyst-1.0.0.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for chess_post_analyst-1.0.0.tar.gz
Algorithm Hash digest
SHA256 7b574ef6e6d9d53fdb53d3595bf113c3cec27321f3eebbc0b1d34386d8a851b6
MD5 4e0062fb8dc9a34eb800cca2678ad843
BLAKE2b-256 1ec3dbaf0274ef23b72844a91da898b2b0c9d521d861955d327cd90ee4167774

See more details on using hashes here.

File details

Details for the file chess_post_analyst-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for chess_post_analyst-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 35dee7dec06579eefd33cb9385e19f96603552fc4c8614677924a624b3051fbb
MD5 3e9495f88a491ce900a2d4482e82d30b
BLAKE2b-256 1e4266576b061bb5ca7012547d631fc5a6e1e5c4cbbf492fb45efe480eb67b72

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page