How it works
A C++ chess engine I built with two teammates for CS 246 at the University of Waterloo, originally drawn in an X11 window. Here it runs on the server and streams every move to your browser in real time.
Architecture
01
Browser
React board sends moves like “move e2 e4” over a WebSocket.
02
Socket.IO server
Node.js starts one engine process per game and relays its output.
03
C++ engine
Validates the move, lets the computer reply, and prints the board as JSON.
Full rules
Castling, en passant, promotion, check, checkmate, stalemate and insufficient material. Every move is checked against a standalone rules module, tested against python-chess over millions of positions.
Four computer levels
Level 1 plays random legal moves. Level 2 prefers captures and checks. Level 3 also escapes threats. Level 4 adds an opening book.
Observer pattern
Every square is observed by the pieces that attack it, so a move only notifies the pieces it affects instead of rescanning the board.
Decorator pattern
Pieces decorate the empty square beneath them. A capture stacks one piece on another, and removing it restores the square.
The C++ source is private under University of Waterloo policy, and available on request. The website and this page are on GitHub.

