A full-featured chess application that allows users to play against AI opponents with multiple difficulty levels.
- Play chess against AI opponents
- Multiple AI difficulty levels (Easy, Medium, Hard)
- User authentication system
- Track game statistics (wins, losses, draws)
- Review previous games
- Save game states for future reference
- Intuitive Pygame-based UI
- Web interface with game history and replay functionality
chess_app/- Main application packagegame/- Chess game logic using python-chessai/- AI opponent implementationui/- Pygame-based user interfaceweb/- Flask web application for user management and statisticsdb/- Database models and interactions for MongoDB
assets/- Game assets (piece images, etc.)
- Python 3.8+
- MongoDB running locally (default: mongodb://localhost:27017/chess_app)
- Clone this repository
- Install dependencies:
pip install -r requirements.txt - Make sure MongoDB is installed and running
There are two main components to this application:
To start the game with the Pygame interface:
python run.py
This will launch the chess game window where you can play against the AI.
To start only the web interface (for user management, statistics, etc.):
python run.py --no-web
This will start the Flask web server. You can then access the web interface at http://localhost:5000.
--no-web: Disable the web server and run standalone game--user-id: User ID for the Pygame UI to connect to--token: Authentication token for the user--difficulty: Difficulty level for the AI (easy, medium, hard)--saved-game-id: ID of the saved game to load--saved-game-fen: FEN of the saved game to load--debug: Enable debug mode--mongo-uri: MongoDB connection URI--quiet: Show minimal server output
- Use the mouse to select and move pieces on the board
- Press keys to access different features:
R- Reset the game1- Set difficulty to Easy2- Set difficulty to Medium3- Set difficulty to HardS- Save the current gameL- Load a saved game
- User registration and login
- Dashboard with game statistics
- Game history and replay
- Leaderboard
- Save and load games
- Launch Pygame interface directly from the browser
To run tests:
pytest
- Python 3.8+
- python-chess - Chess logic library
- Pygame - Game UI
- Flask - Web backend
- Flask-Login - User authentication
- PyMongo/MongoDB - Database
- Bootstrap - Frontend styling
This project is open source and available under the MIT License.