This project is a web-based Xiangqi (Chinese Chess) application that allows users to play against different AI opponents. It features a modern, clean interface and a decoupled front-end and back-end architecture.
- Play Xiangqi: A fully functional Xiangqi board with all standard rules implemented.
- Selectable AI Opponents: Choose to play against different AI agents with varying difficulty.
- Random Agent: A simple agent that makes random legal moves.
- Minimax (Expert) Agent: A more advanced agent using Minimax search with Alpha-Beta Pruning, Iterative Deepening, and a heuristic evaluation function with Piece-Square Tables.
- Modern UI: A clean, responsive user interface built with React.
- Separated Frontend/Backend: A robust architecture that separates the user interface (React) from the game logic and AI (Python/FastAPI).
- Frontend:
- React
- TypeScript
- Vite
- Backend:
The project is organized into two main directories:
/front-end: Contains the React/TypeScript user interface./back-end: Contains the Python/FastAPI server, which hosts the game logic and AI agents.
To run the project locally, you will need to start both the back-end server and the front-end application.
First, navigate to the back-end directory and set up the Python environment.
cd back-end
# It is recommended to create a virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows, use `.venv\Scripts\activate`
# Install dependencies
pip install -r requirements.txt
# Run the server
uvicorn main:app --reloadThe back-end server will be running on http://127.0.0.1:8000.
In a separate terminal, navigate to the front-end directory.
cd front-end
# Install dependencies
npm install
# Run the development server
npm run devThe front-end application will be available at http://localhost:5173 (or another port if 5173 is busy). Open this URL in your browser to play the game.
