A modern chess game implementation with real-time AI-powered position evaluation and a beautiful graphical interface. The game features a professional design, intuitive controls, and machine learning-based position analysis.
- Interactive chess board with legal move validation
- Real-time position evaluation using machine learning
- Visual advantage bar showing current game state
- Move history display (last 10 moves)
- Current player indicator
- Chess coordinates (a-h, 1-8)
- Reset game functionality (R key)
- Cancel selection (ESC key)
- Pawn promotion with visual piece selection dialog
- Modern, clean design with professional color scheme
- Smooth hover effects and piece selection highlighting
- Side panel with game information
- Responsive board sizing and centering
- Shadow effects and visual feedback
- Alternating move history background
- Board coordinates for easy move reference
- Centered promotion dialog with piece selection
- Machine learning model for position evaluation
- Real-time advantage prediction
- Feature extraction from board positions
- Gradient-based advantage visualization
- Pygame-based graphical interface
- Python-chess library for game logic
- RandomForest model for position evaluation
- Efficient board state management
- Frame rate limiting for smooth gameplay
- Error handling for resource loading
- Python 3.8+
- pygame>=2.5.0
- python-chess>=1.10.0
- scikit-learn>=1.3.0
- numpy>=1.24.0
- joblib>=1.3.0
- Clone the repository:
git clone https://github.com/ayush-jadaun/chess-game.git
cd chess-game- Set up a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Run the game:
python src/game/main.pychess-game/
├── src/
│ ├── game/
│ │ ├── __init__.py
│ │ └── main.py # Main game implementation
│ ├── engine/
│ │ ├── __init__.py
│ │ └── model.py # Chess engine and ML model
│ └── utils/
│ ├── __init__.py
│ └── constants.py # Game constants
├── assets/
│ ├── images/ # Chess piece images
│ │ ├── bB.png # Black bishop
│ │ ├── bK.png # Black king
│ │ ├── bN.png # Black knight
│ │ ├── bP.png # Black pawn
│ │ ├── bQ.png # Black queen
│ │ ├── bR.png # Black rook
│ │ ├── wB.png # White bishop
│ │ ├── wK.png # White king
│ │ ├── wN.png # White knight
│ │ ├── wP.png # White pawn
│ │ ├── wQ.png # White queen
│ │ └── wR.png # White rook
│ └── models/
│ └── chess_model.pkl # Trained ML model
├── data/
│ └── pgn/ # PGN game data for training
├── requirements.txt # Project dependencies
└── README.md # Project documentation
-
Starting the Game:
- Run the game using
python src/game/main.py - The board will appear with pieces in their starting positions
- Run the game using
-
Making Moves:
- Click on a piece to select it
- Valid moves will be highlighted with circles
- Click on a highlighted square to move
- Press ESC to deselect a piece
-
Pawn Promotion:
- When a pawn reaches the opposite end of the board (8th rank for White, 1st rank for Black)
- A promotion dialog will appear in the center of the screen
- Click on the piece you want to promote to (Queen, Rook, Bishop, or Knight)
- Press ESC to cancel the promotion and choose a different move
-
Game Controls:
- R: Reset the game
- ESC: Cancel piece selection or promotion dialog
- Mouse: Select and move pieces
-
Game Features:
- The side panel shows the current player and advantage
- Move history displays the last 10 moves
- The advantage bar shows the current position evaluation
- Chess coordinates help identify squares
- Hover effects show which square you're pointing at
- Visual feedback for piece selection and legal moves
The chess engine uses a machine learning model trained on:
- PGN game data
- Position features (768 binary features representing piece positions)
- RandomForest regressor for position evaluation
- Add multiplayer support
- Implement game saving/loading
- Add difficulty levels
- Improve AI model accuracy
- Add sound effects
- Implement undo/redo
- Add game statistics
- Create tutorial mode
- Add keyboard shortcuts for moves
- Implement move validation hints
- Ayush Jadaun - GitHub
For support, please open an issue in the GitHub repository or contact the author.