This is a chess game and engine written from scratch in C++20, with a custom OpenGL renderer built on GLFW. It enforces every rule of chess (castling, en passant, promotion, repetition and insufficient-material draws) and includes a computer opponent at four strengths, chess clocks, match scoring, and sound effects. The same code runs natively on macOS, Linux, and Windows, and in the browser through WebAssembly. You can play it right on this page!
The project is split into two parts: a pure C++ engine library with no graphics dependencies, and a GUI layer on top of it. The engine uses a mailbox board representation with FEN parsing and fully legal move generation, verified against standard perft node counts up to depth 6. Keeping it separate from the GUI meant the rules and search could be tested headlessly.
The computer opponent uses negamax with alpha-beta pruning, iterative deepening, and a quiescence search so it doesn't stop calculating in the middle of an exchange. Moves are ordered by the previous iteration's best move, MVV-LVA captures, and killer moves, and positions are cached in a transposition table keyed by Zobrist hashes. The evaluation combines material with piece-square tables, blending the king's tables between middlegame and endgame by game phase. Weaker difficulty levels add evaluation noise, disable quiescence, and occasionally pick deliberately worse moves so they play more like a human beginner.
The renderer batches quads into a single vertex buffer per texture and sticks to the subset shared by OpenGL 3.3 core and OpenGL ES 3.0, so the exact same rendering code runs on the desktop and in WebGL 2. The browser version is compiled with Emscripten, which provides GLFW on top of the canvas and Web Audio for sound. Since the browser build has no threads, the engine is also compiled as a separate WebAssembly module that runs in a Web Worker, so the board stays responsive while the computer thinks.
Pick an opponent and time control from the menu, then drag or click pieces to move. Click inside the board to use the keyboard: ←/→ step through moves, F flips the board, N starts the next game, and Esc opens the menu.