Skip to content

MegaCoderNerd/960analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

31 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Chess 960 Analysis

A comprehensive Chess 960 (Fischer Random) game review website that allows users to analyze their games with Stockfish engine analysis. The UI closely resembles Chess.com's game review interface with a modern dark theme.

Chess 960 Analysis TypeScript React Vite

Features

๐ŸŽฎ Game Import Options

  • Chess.com Integration: Fetch games by username, date range, or direct URL
  • Lichess Integration: Fetch games by username, date range, or direct URL
  • Direct Import: Import games via PGN or FEN notation

โ™Ÿ๏ธ Chess 960 Support

  • Proper handling of Fischer Random starting positions (all 960 positions)
  • Correct castling rules for Chess 960
  • Automatic detection and display of starting position number (1-960)

๐Ÿ” Stockfish Analysis Engine

  • Browser-based Stockfish.js (WebAssembly) for fast analysis
  • Configurable analysis depth (default: 18)
  • Multi-PV analysis showing top 3 engine lines
  • Real-time position evaluation

๐Ÿ“Š Chess.com-Style UI

  • Interactive Chess Board: Drag and drop pieces, arrow annotations, smooth animations
  • Evaluation Bar: Visual representation of position evaluation
  • Move Classification:
    • โœจ Brilliant (cyan/teal)
    • ! Great (blue)
    • โœ“ Best/Excellent (green)
    • โ—‹ Good (light green)
    • โ–ก Book (gray)
    • ?! Inaccuracy (yellow)
    • ? Mistake (orange)
    • ?? Blunder (red)
    • โ˜“ Missed Win (red)
  • Accuracy Score: Per-player accuracy percentage based on centipawn loss
  • Move List Panel: Scrollable, clickable move list with color-coded badges
  • Engine Lines: Top 3 engine lines with evaluations and continuations

โŒจ๏ธ Keyboard Shortcuts

  • โ† / โ†’: Previous/Next move
  • Home / End: First/Last move
  • F: Flip board

๐ŸŽจ Design

  • Dark theme matching Chess.com's aesthetic
  • Smooth 60fps animations
  • Responsive design (tablet/desktop)
  • Modern, clean interface

Tech Stack

  • Frontend: React 19.2 + TypeScript 5.9
  • Build Tool: Vite 7.2
  • Styling: Tailwind CSS 3.4
  • Chess Logic: chess.js for move validation
  • Board: chessground for interactive chess board
  • Engine: Stockfish.js (WebAssembly) - runs entirely in browser
  • APIs: Chess.com & Lichess public APIs

Getting Started

Prerequisites

  • Node.js 18+ and npm

Installation

  1. Clone the repository: ```bash git clone https://github.com/MegaCoderNerd/960analysis.git cd 960analysis ```

  2. Install dependencies: ```bash npm install ```

  3. Start the development server: ```bash npm run dev ```

  4. Open your browser and navigate to `http://localhost:5173\`

Build for Production

```bash npm run build ```

The production build will be in the `dist` folder.

Preview Production Build

```bash npm run preview ```

Usage

Importing a Game

  1. Direct Import (Recommended for testing):

    • Click the "Direct" tab
    • Select "PGN" or "FEN"
    • Paste your game notation
    • Click "Import"
  2. Lichess:

    • Click the "Lichess" tab
    • Enter a Lichess username or game URL
    • Select from the list of Chess960 games
  3. Chess.com:

    • Click the "Chess.com" tab
    • Enter a Chess.com username
    • Select year and month
    • Choose from the filtered Chess960 games

Analyzing a Game

Once a game is loaded:

  1. Use the navigation buttons or arrow keys to move through the game
  2. The Stockfish engine automatically analyzes each position
  3. View the evaluation bar, engine lines, and move classifications
  4. Check player accuracy scores in the left sidebar
  5. Click on any move in the move list to jump to that position

Example PGN for Testing

```pgn [Event "Chess960 Game"] [Site "Online"] [Date "2024.01.01"] [White "Player1"] [Black "Player2"] [Result "1-0"]

  1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 4. Ba4 Nf6 5. O-O Be7 6. Re1 b5 7. Bb3 d6 8. c3 O-O 9. h3 Nb8 10. d4 Nbd7 1-0 ```

Project Structure

``` src/ โ”œโ”€โ”€ components/ โ”‚ โ”œโ”€โ”€ Board/ # Chess board, evaluation bar, controls โ”‚ โ”œโ”€โ”€ Analysis/ # Engine lines, accuracy display, move classification โ”‚ โ”œโ”€โ”€ GameImport/ # Import components for different sources โ”‚ โ”œโ”€โ”€ MoveList/ # Move list and move items โ”‚ โ””โ”€โ”€ Layout/ # Header and footer โ”œโ”€โ”€ hooks/ # Custom React hooks โ”‚ โ”œโ”€โ”€ useStockfish.ts # Stockfish engine hook โ”‚ โ”œโ”€โ”€ useChessGame.ts # Chess game state management โ”‚ โ””โ”€โ”€ useGameImport.ts # Game import logic โ”œโ”€โ”€ services/ # API integrations โ”‚ โ”œโ”€โ”€ chesscom.ts # Chess.com API โ”‚ โ”œโ”€โ”€ lichess.ts # Lichess API โ”‚ โ””โ”€โ”€ analysis.ts # Analysis utilities โ”œโ”€โ”€ utils/ # Utility functions โ”‚ โ”œโ”€โ”€ chess960.ts # Chess 960 position handling โ”‚ โ”œโ”€โ”€ moveClassification.ts # Move quality classification โ”‚ โ””โ”€โ”€ accuracy.ts # Accuracy calculation โ”œโ”€โ”€ types/ # TypeScript type definitions โ”œโ”€โ”€ workers/ # Web Workers โ”‚ โ””โ”€โ”€ stockfish.worker.ts # Stockfish Web Worker โ””โ”€โ”€ App.tsx # Main application component ```

API Integration

Chess.com API

Lichess API

Performance Notes

  • Stockfish analysis runs in a Web Worker for non-blocking UI
  • Analysis is cached to avoid re-computation
  • Chessground provides smooth 60fps board animations
  • Lazy loading of Stockfish WASM on first analysis

Browser Compatibility

  • Chrome/Edge: โœ… Full support
  • Firefox: โœ… Full support
  • Safari: โœ… Full support (WebAssembly required)
  • Mobile browsers: โš ๏ธ Limited support (desktop recommended)

Contributing

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

License

MIT License - feel free to use this project for learning or building your own chess analysis tools.

Acknowledgments

Support

For issues, questions, or feature requests, please open an issue on GitHub.


Made with โ™Ÿ๏ธ by MegaCoderNerd

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors