A lightweight 2D chess game built with pygame. Play locally against a simple engine or use it as a base for your own chess experiments.
- Interactive 2D chessboard with piece images
- Click-to-move controls
- Basic move logic & game state tracking (
ChessEngine.py) - Works out-of-the-box with
pygame
- Python 3.10+ (tested up to 3.13)
- pygame β₯ 2.6.1
Install pygame:
python -m pip install pygameOr in a virtual environment:
python -m venv .venv
.\\.venv\\Scripts\\Activate.ps1
python -m pip install --upgrade pip pygameFrom the project root:
python Chess/ChessMain.pyOr with an absolute path (Windows example):
& C:/Users/BILAL/AppData/Local/Programs/Python/Python313/python.exe c:/Users/BILAL/Documents/GitHub/Chess/Chess/ChessMain.pyβ
Images are loaded relative to ChessMain.py, so the game runs regardless of your working directory.
Chess/
ChessMain.py # GUI & main loop
ChessEngine.py # Game state & move logic
Images/ # Piece images (wp.png, bR.png, ...)
-
ModuleNotFoundError: No module named 'Chess'β Already fixed (now usesimport ChessEngine). -
Image load errors β Ensure
Chess/Images/has all piece PNGs. Errors will print full paths to help debug. -
No window / pygame crash β Confirm youβre using the same Python environment where
pygameis installed.
Short-term
- Full legal moves (castling, en passant, promotion)
- Undo/redo & move history
- Move highlighting
Medium-term
- Stronger engine (minimax + alpha-beta)
- FEN/PGN save & load
- Chess clocks
Long-term
- Online multiplayer
- Packaged builds (PyInstaller)
- CI & unit tests
Contributions welcome! Open an issue or draft PR before big changes.