A fully functional chess game implemented in TypeScript with a web-based UI.
- Complete chess rules implementation
- Interactive UI with piece selection and move highlighting
- Special moves: castling, en passant, pawn promotion
- Check and checkmate detection
- Game state tracking and display
- AI competition mode using Stockfish chess engine
- Responsive design
- Select a game mode from the dropdown menu:
- Human vs. Human: Play against another person
- Human vs. AI: Play against the Stockfish chess engine
- If playing against AI, select the AI's color (white or black)
- Click on a piece to select it
- The possible moves for that piece will be highlighted
- Click on a highlighted square to move the piece
- The game will automatically switch turns and update the game state
- If playing against AI, it will automatically make its move after you
- If a player is in check, it will be displayed in the status
- When the game ends (checkmate or stalemate), the result will be displayed
- Click the "Reset Game" button to start a new game
The chess game is implemented with a clean architecture separating the game logic from the UI:
Board
: Represents the chess board and handles piece placement and movementMoveValidator
: Validates moves according to chess rules and detects check/checkmateGame
: Manages the game state, player turns, and move historyStockfishService
: Integrates the Stockfish chess engine for AI moves
ChessBoard
: Renders the chess board and handles user interactions- CSS styling for the board, pieces, and game controls
This project is built with Vite and TypeScript. To run the development server:
npm install
npm run dev
To build for production:
npm run build
- Move history display
- Time controls
- Adjustable AI difficulty levels
- Online multiplayer
- Save/load game functionality