Chess
A modern chess game built with Svelte 5, TypeScript, and Vite.
Features
- Play modes — Player vs Player, Player vs AI, AI vs AI
- AI opponent — Minimax with alpha-beta pruning at 4 difficulty levels, runs in a Web Worker
- Full FIDE rules — Castling, en passant, pawn promotion, stalemate, threefold repetition, 50-move rule, insufficient material draws
- Chess clocks — Untimed, bullet, blitz, rapid, or custom time controls with increment
- Drag and drop — Click-to-move and drag-and-drop piece movement with touch support
- Move history — Algebraic notation with review/navigation (forward, back, jump to start/end)
- Sound effects — Move, capture, check, castle, and game-over sounds with toggle
- Themes — Classic, Modern, and Dark board themes
- PGN export — Export games in standard Portable Game Notation
- Save/load — Auto-save and manual save with local storage
- Move hints — AI-powered move suggestions
- Keyboard navigation — Full arrow key navigation with ARIA announcements
- Responsive layout — Adapts to desktop and mobile screens
Tech Stack
- Svelte 5 with runes (
$state, $derived, $effect)
- TypeScript for type safety
- Vite 7 for dev server and bundling
- Vitest for testing (382 tests)
- Web Worker for non-blocking AI computation
- cburnett/lichess SVG pieces
Getting Started
npm install
npm run dev
Open http://localhost:5173 in your browser.
Scripts
| Command |
Description |
npm run dev |
Start dev server |
npm run build |
Production build |
npm run preview |
Preview production build |
npm run check |
Type-check with svelte-check and tsc |
npm test |
Run all tests |
npm run test:watch |
Run tests in watch mode |
Project Structure
src/
lib/
ai/ # Minimax AI with alpha-beta pruning + Web Worker
engine/ # Board state, move generation, rules, notation
components/ # Svelte UI components (board, panels, landing, shared)
pieces/ # cburnett SVG chess piece components
sounds/ # Audio manager and sound effects
stores/ # Reactive stores (game, settings, timer, saved games)
themes/ # Board color themes
utils/ # Local storage helpers