A terminal-based chess game written in Python 3, supporting local play against a simple AI or another player via network. This project is a Python port of the author's C++ chess program.
- Playable against a computer AI or another human
- Text-based terminal interface
- Supports standalone, server, and client modes for network play
- Basic move and board validation
- Simple AI: makes moves via decision trees and piece evaluation
- Unicode chess pieces shown in the terminal for a visually clear board
- Python 3.10 or above
- Works in any terminal (Linux, macOS, or Windows with Unicode support)
Clone the repository:
git clone https://github.com/matthewJamesAbbott/Python-Chess.git
cd Python-ChessStandalone (vs computer or two on the same device):
python3 main.pyServer mode (wait for remote player):
python3 main.py -sClient mode (connect to a server):
python3 main.py -c [SERVER_IP_ADDRESS]Help:
python3 main.py --help- Follow terminal prompts:
Enter the row and column for the piece to move (row: 1–8, column: a–h) and the move destination. - Use
9at any prompt to exit immediately. - The board and pieces print in Unicode for clarity in compatible terminals.
main.py- Program entrypoint & command-line parser; sets up mode (standalone, client, server).Game.py- Main game logic, move validation, board printing, AI moves, and user move handling.Engine.py- Contains AI class: builds a move tree, selects moves for computer player.MoveCalculator.py- Calculates all legal moves for a piece and provides move lists and validation.Board.py- Simple 8x8 chessboard implementation, with setters/getters for positions.
- The AI uses a decision tree of possible moves, with a basic material-evaluation strategy (captures prioritized, fallback if move puts AI in check).
- Designed to mimic the logic from the original C++ version.
- Terminal only (no GUI).
- Protocol/network play is basic and uses port 9008, both endpoints must be able to connect.
- No save/load or persistence of games.
- Not a competitive chess AI (suitable for casual play/learning).
This code is not licensed for redistribution or commercial use;
it is published here for learning and personal exploration.Created by Matthew James Abbott.
Do not reuse or redistribute without explicit permission.
Contact via GitHub for any permission requests.
Enjoy Python Chess!
