PythonChess
A two-player chess game written in Python and Pygame, now running in the browser from the same source through WebAssembly.
Play the original Python game.
Two players, one device. Select a piece, then choose a highlighted legal move. Press R or use New Game to restart.
Running the project's Python board, piece, GUI, and main-loop modules through CPython + Pygame WebAssembly—not a JavaScript recreation.
- Legal-move highlighting
- King-safety validation
- Checkmate & stalemate
- Instant restart
Building chess from scratch forces you to make every rule explicit: piece geometry, blocked paths, turn order, pinned pieces, and the recursive question of whether a move exposes your own king. Rules you have followed for years turn out to be surprisingly hard to state precisely. The original game was also desktop-only, so nobody visiting a portfolio could actually play it.
I modelled the board and pieces explicitly, separated movement from rendering, and filtered candidate moves against the resulting king state. For the portfolio build I packaged the existing Python modules and Pygame interface with CPython and pygame-ce for WebAssembly instead of rewriting the rules in JavaScript.
Rules engine
Movement for every piece, blocked-path validation, turn-based play, king-safety filtering, and automatic queen promotion.
Check & checkmate detection
Validates that moves don’t leave the king in check and detects checkmate and stalemate positions.
Interactive board
A Pygame UI with legal-move and capture markers, conventional White/Black presentation, game status, and instant restart.
Python in the browser
The original Python board, piece, GUI, and main-loop modules run through WebAssembly inside this case study—no JavaScript rules-engine replacement.
Separating game state from rendering paid off twice: it made rule edge cases fixable in isolation, and later it let the same Pygame project move into the browser untouched. The version you can play here is the original code, running on a web runtime.