GrandMentor - AI Chess Coaching Platform

Inspiration

Chess has always been a game of intellectual challenge, but learning to improve can be frustratingly difficult. Traditional methods like books and videos lack personalization, while professional coaches are expensive and not always accessible. We were inspired to create GrandMentor after experiencing firsthand how difficult it is to get personalized, high-quality chess coaching without spending hundreds of dollars per hour. We wanted to democratize access to chess improvement by combining the analytical power of traditional chess engines with the coaching wisdom of large language models.

What it does

GrandMentor is an AI-powered chess coaching platform that provides:

  1. Instant Game Analysis - Upload any PGN file or input positions to get comprehensive analysis
  2. Personalized Coaching - Receive insights tailored to your skill level and specific position
  3. Tactical Detection - Automatic identification of tactical opportunities (pins, forks, etc.)
  4. Visual Board Annotations - Interactive visual cues showing threats, defenders, and key squares
  5. Natural Language Explanations - Clear, human-like explanations rather than just engine evaluations
  6. Conversation Interface - Ask follow-up questions about positions and receive AI coaching responses

The platform combines traditional chess engine analysis with advanced LLM capabilities, providing both technical precision and human-like coaching wisdom.

Agentic Loop

The ChessAssist application implements a sophisticated agentic loop that enables continuous interaction between components to deliver comprehensive chess analysis. Here's how it works:

Core Agentic Loop Components

  1. Input Processing

    • Position reception (FEN string)
    • Game history collection (PGN format)
    • User query interpretation
  2. Multi-level Analysis Pipeline

    • Engine evaluation (Stockfish)
      • Numerical position assessment
      • Principal variation calculation
      • Multiple candidate moves analysis
    • Tactical pattern recognition
      • Pins, forks, discovered attacks detection
      • Threat assessment
      • Opportunity identification
    • Material and activity assessment
      • Piece value calculations
      • Mobility metrics
      • King safety evaluation
  3. LLM-Enhanced Interpretation

    • Context assembly from analysis data
    • LLM prompt engineering and invocation
    • Response parsing and structure formation
  4. Feedback Presentation

    • Position summary
    • Key tactical elements
    • Strategic recommendations
    • Visual board annotations

Loop Execution Flow

  1. User submits a position → System processes FEN string
  2. Parallel analysis tracks (engine, tactical, material) execute
  3. Results are aggregated and structured
  4. LLM enhances analysis with natural language insights
  5. Comprehensive analysis returns to user interface
  6. Telemetry captures performance metrics throughout
  7. User can iterate with follow-up questions or position modifications

Adaptive Capabilities

  • Error recovery mechanisms ensure partial analysis delivery even if components fail
  • Telemetry-driven optimization adjusts resource allocation based on usage patterns
  • Configurable analysis depth allows performance tuning for different environments

How we built it

GrandMentor is built using a modern tech stack:

  • Backend: Python FastAPI providing a robust API layer
  • Chess Engine: Stockfish integration for precise position evaluation
  • LLM Integration: Anthropic Claude and OpenAI models for coaching insights
  • Frontend: React with Next.js for a responsive, interactive interface
  • Chess Visualization: Interactive board using React Chess components
  • Tactical Analysis: Custom algorithms for detecting common tactical patterns
  • Data Pipeline: Comprehensive flow from raw position data through engine analysis to AI coaching
  • Telemetry: Weave integration for monitoring and dashboards

We implemented a multi-stage analysis pipeline that combines concrete tactical detection with LLM-powered annotation and coaching, ensuring both accuracy and insightful commentary.

Challenges we ran into

Building GrandMentor presented several significant challenges:

  1. LLM Hallucinations - Chess is a domain where factual accuracy is critical, but LLMs sometimes "hallucinate" incorrect moves or evaluations. We solved this by grounding LLM analysis with concrete tactical detection and engine evaluations.

  2. Performance Optimization - Chess analysis can be computationally expensive, especially when using both traditional engines and LLMs. We implemented efficient caching and parallel processing to maintain responsiveness.

  3. Technical/Human Balance - Finding the right balance between technical engine evaluations and human-like coaching advice was difficult. We developed structured prompts that guide the LLM to provide both technical accuracy and accessible explanations.

  4. Visual Annotation Complexity - Transforming LLM outputs into visual board annotations required careful prompt engineering and output parsing.

  5. LLM Costs - API costs for LLM calls can add up quickly. We implemented smart throttling and a skip_llm option to control costs while maintaining value.

Accomplishments that we're proud of

  1. Grounded LLM Analysis - We successfully eliminated chess hallucinations by creating a tactical detection system that identifies concrete patterns before LLM analysis.

  2. Comprehensive Monitoring - Our Weave integration provides detailed telemetry on all aspects of the system, from API request timings to LLM token usage.

  3. Accessible Interface - We created an intuitive interface that makes advanced chess analysis approachable for players of all levels.

  4. Multi-Model Support - The platform seamlessly supports both OpenAI and Anthropic models, allowing for flexibility and resilience.

  5. Detailed Visual Annotations - Our system generates insightful board annotations that highlight threats, defenders, and key squares directly on the board.

Built With

Share this project:

Updates