This project is a browser-based chess game built using C++ and Emscripten. It features a functional and user-friendly interface designed with HTML, CSS, and JavaScript. While the initial goal was to create a chess game entirely in C++, I decided to leverage WebAssembly (WASM) to bring the project to the web, creating an engaging visual experience.
The core chess logic resides in chess.hh
and chess.cc
, which can also be reused in other C++ chess applications. This project demonstrates a balance between performance and usability, integrating advanced features while maintaining simplicity.
- Full Chess Rules: All standard chess rules are implemented, including special moves like castling, en passant, and pawn promotion.
- WebAssembly for Performance: The game logic is compiled into WebAssembly for seamless execution in modern browsers.
- Stockfish Integration: A Stockfish engine (ported to WASM) is included, allowing users to play against the computer or adjust difficulty via a settings tab.
- Responsive UI: A clean and simple UI designed for both desktop and mobile browsers, with draggable pieces and a visual representation of the game state.
To compile and run the project locally, follow these steps:
-
Install Emscripten: Ensure you have the Emscripten SDK installed. You can follow the instructions here.
-
Compile the Code: Run the following command to compile the C++ code into WebAssembly or directly use
chess.js
andchess.wasm
:make
-
Run Locally: Open the generated chess.html file in any modern web browser to play the game locally.
This project utilizes a combination of open-source tools and assets. Below are links to the key components and resources used:
- Emscripten documentation — Documentation for compiling C++ into WebAssembly.
- Stockfish.js — A WebAssembly port of the Stockfish chess engine.
- Chess Piece SVGs — Chess piece graphics designed by Cburnett, used under a Creative Commons license.
Special thanks to:
- Lichess.org for providing the WebAssembly port of the Stockfish engine, which enhances the gameplay experience.
- Cburnett for designing the beautiful chess piece SVGs that are used in this project.
This project is licensed under the GNU General Public License v3.0.