A modern chess application built using React, JavaScript, and chess.js. The project includes game logic, timers, themes, sounds, animations, move history, captured pieces, and support for playing against Stockfish AI.
- React
- JavaScript
- chess.js
- CSS
- Web Workers
- HTML5 Audio API
- Stockfish
- 8×8 board
- Unicode chess pieces
- Legal move highlighting
- Selected square highlighting
- Capture highlighting
- Automatic pawn promotion to Queen
- Move validation through chess.js
Two-player local mode.
Human plays White.
Stockfish plays Black automatically.
Initial time:
10:00
Features:
- Active player's timer decreases.
- Timer pauses during game pause.
- Timer stops when game ends.
- Timers reset when starting a new game.
- Active player's clock is highlighted.
Features:
- Pause button
- Resume button
- Board disabled during pause
- Timers stop during pause
- Status updates accordingly
Moves are stored in SAN format.
Example:
1. e4 e5
2. Nf3 Nc6
3. Bb5 a6
Move history is displayed in a scrollable panel.
Captured pieces are displayed separately.
Black pieces captured by White.
White pieces captured by Black.
Wood-inspired interface.
Modern dark interface.
Theme switching is implemented using CSS variables.
Generated using the Web Audio API.
Played after normal moves.
Played after captures.
Played when a king is in check.
Played on:
- Checkmate
- Timeout
Detects checkmate and declares the winner.
Recognizes stalemate positions.
Handles draw conditions.
If White reaches zero:
Time Out! Black Wins
If Black reaches zero:
Time Out! White Wins
Further moves are disabled.
When a player's clock reaches one minute:
- A popup appears.
- An animated king enters from the side.
- A speech bubble displays:
One Minute Left
The popup disappears automatically after five seconds.
Animations used:
- slideInLeft
- bubbleBounce
When the game ends:
- Dark overlay appears.
- Winner card is displayed.
- Winner message is shown.
- Animated queen enters.
- New Game button is provided.
Confetti particles are generated dynamically.
Animation:
@keyframes confettiFallTriggered after victory.
Implemented through a Web Worker.
Human:
White
AI:
Black
Flow:
Player Move
↓
AI Thinking
↓
Best Move Computed
↓
AI Move Executed
Stockfish commands:
engine.postMessage(
"position fen " + game.fen()
);
engine.postMessage(
"go movetime 500"
);Custom chess-themed wallpaper.
CSS properties:
background-size: cover;
background-position: center;A translucent overlay is added for readability.
The interface uses:
box-shadowborder-radiusUsed for theme support.
- slideInLeft
- slideInRight
- bubbleBounce
- popupScaleIn
- confettiFall
- fadeIn
moveHistorySan
selectedSquare
legalMoves
whiteTime
blackTime
paused
theme
gameOverInfo
oneMinuteWarning
playAI
isThinkingManages game and UI state.
Handles:
- Timers
- Sounds
- Warnings
- Game over detection
- Stockfish communication
Optimizes:
- Chess object reconstruction
- Board generation
- Move history
- Captured pieces
Stores:
- Warning flags
- Sound indices
src/
│
├── components/
│ Board.js
│ Square.js
│
├── chess.jfif
│
├── App.js
│
public/
│
├── stockfish-18-lite-single.js
├── stockfish-18-lite-single.wasm
│
package.json
- Wood
- Purple
- Pink
- Neon
Replace click-based movement.
Implement using Socket.io.
Authentication and rating system.
Display opening names.
Allow downloading completed games.
Move rollback functionality.
Store and retrieve PGN/FEN.
This project provided practical experience with:
- React Hooks
- State management
- useEffect and useMemo
- chess.js
- Stockfish integration
- Web Workers
- CSS animations
- Web Audio API
- Game logic implementation
- Component-based architecture
- UI/UX design
- Performance optimization
- Debugging complex state interactions
Niyati Aggarwal
Built using React, chess.js, and Stockfish to create a complete and interactive chess experience.