A compact chess application combining a React frontend with a C++ engine compiled to WebAssembly (WASM).
This project runs a custom chess engine in the browser using WebAssembly for move generation and search. The UI is built with React (Vite) and communicates with the compiled engine for move generation in PvE mode.
- Move validation including En Passant, Castling (kingside/queenside), and Pawn Promotion
- Check and Checkmate detection
- Game modes: PvP (local) and PvE (against the engine)
- Side selection: play as White or Black
The engine is implemented in C++ and compiled to WebAssembly for use in the browser.
- Uses bitboards (64-bit integers) to represent board state efficiently.
- Search algorithm: Minimax with Alpha-Beta pruning
- Fixed search depth (currently 5 plies)
- Evaluation consists of material counting and piece-square tables (PST). Basic checkmate/stalemate scoring is included.
src/
├── components/ # React UI (Board, GameMenu, Pieces, Squares)
├── engine/ # C++ source + generated WASM glue (engine.cpp, bitBoard.*)
│ ├── engine.cpp
│ ├── bitBoard.cpp/h
│ └── engine.js # WASM glue/runtime wrapper
├── utils/ # JS game logic and helpers (move validation, workers)
└── assets/ # SVG pieces, alternative piece sets, sounds
Key files:
- src/main.jsx - App entry
- src/components/Board.jsx - Board rendering
- src/engine/engine.js - WASM loader/shim
- Node.js
- C++ compiler (only required if you rebuild the WASM engine)
- Emscripten (only required if you recompile the C++ to WASM)
Install dependencies:
npm installRun development server:
npm run devBuild for production:
npm run buildIf you need to recompile the engine to WASM, follow the steps in the engine/ folder and ensure Emscripten is configured.
- Engine search depth is hardcoded to 5 plies
- No iterative deepening or time management
- No opening book or endgame tablebases
- Implement check/checkmate detection
- Handle En Passant & Castling
- Pawn Promotion
- Basic engine (Minimax)
- Move ordering optimizations
- Quiescence search
- Time control management / iterative deepening