A Python implementation of Chinese Chess (Xiangqi) with Pygame, currently being upgraded to include an AlphaZero-style AI.
- UI Overhaul: Expanded window layout (800×800 → 1000×800) with a new sidebar panel featuring turn indicator, game timer, standard Chinese notation move log, and control buttons (Restart, Save FEN).
- Rule Engine: Implemented Zobrist Hashing for position tracking, perpetual check/chase detection (offender loses on 3-fold repetition), and stalemate detection (no legal moves = loss).
- Chinese Notation: Real-time standard Chinese Chess notation (e.g., 炮二平五) displayed in the sidebar.
- FEN Support: Save and load board positions using standard FEN strings.
- Code Quality: Achieved Pylint 10.00/10. Full PEP 8 compliance with project rename (
MyChess→my_chess). Complete docstring coverage. - Testing: 24 unit tests covering all 7 piece types' movement rules, stalemate, repetition penalty, and notation correctness.
- Coordinate System: Added UCCI/ICCS coordinate conversion for future AI integration.
- Modernization: Migrated legacy Python 2 code to Python 3.8+ standards (Type Hints,
dataclasses, newsuper()syntax). - Engineering: Added
pyproject.toml, standard.gitignore, and pinned dependencies inrequirements.txt. - Infrastructure: Introduced
run.pyas a unified entry point to fix import path issues. - Code Style: Enforced
blackandisortformatting rules. - Fixes: Resolved Python 3 crash in CLI mode input handling.
- Python 3.8+
- Git
-
Clone the repository
git clone https://github.com/mm12432/my_chess.git cd my_chess -
Set up Virtual Environment (Recommended)
# Create virtual environment python -m venv .venv # Activate virtual environment # Windows: .venv\Scripts\Activate # Linux/MacOS: # source .venv/bin/activate
-
Install Dependencies
pip install -r requirements.txt
Run the GUI Game (Default):
python run.pyRun the Terminal Mode:
python run.py cliThis project follows modern python best practices.
- Type checking:
mypy(Planned) - Code formatting:
black - Tests:
pytest