Welcome to this versatile Chess Game project! Built using Python and Pygame, it combines a variety of gameplay modes, including single-player (against an AI bot powered by Stockfish), local multiplayer, and online multiplayer. The game incorporates customizable rules, advanced features, and real-time tracking of moves, scores, and captured pieces.
- Single Player:
- Play against an AI bot integrated with Stockfish's API for decision-making.
- Adjustable difficulty levels: Beginner, Intermediate, and Advanced.
- Multiplayer:
- Local Play: Two players can play on the same computer.
- Online Play: Play with a friend over the network using real-time move synchronization.
- Movement Options:
- Click: Select and move pieces by clicking.
- Drag-and-Drop: Move pieces intuitively by dragging them across the board.
- Customizable Rules:
- Toggle features like En Passant, Castling, Pawn Promotion, and Stalemate from the settings menu.
- Choose promotion options (e.g., queen, rook, bishop, knight).
- Bot Gameplay:
- Powered by Stockfish's API for sophisticated decision-making.
- Adjustable time limit for the bot's moves.
- Undo/Redo Moves:
- Undo or redo player and bot moves with updates to captured pieces and scores.
- Move History & Highlights:
- A scrollable log displays all moves made during the game.
- Highlights the last move for both players and shows legal moves when selecting pieces.
- Player Names & Score Tracking:
- Input custom player names reflected in the scoreboard.
- Captured pieces are displayed in real-time.
- Sound Effects:
- Customizable sounds for moves, captures, and other events.
- Python 3.x
- Pygame library
- Stockfish chess engine
-
Clone the repository:
git clone https://github.com/your-repo-link cd chess-game -
Install dependencies:
pip install pygame chess
-
Download and set up Stockfish:
- Visit the Stockfish downloads page.
- Choose the appropriate version for your operating system.
- Extract the downloaded files and place the
stockfishorstockfish.exebinary in thestockfish/folder of the project.
-
Run the game:
python main.py
- Choose the difficulty level.
- Move pieces using click or drag-and-drop. The bot responds after each move based on Stockfish's calculations.
- Local: Two players share the same computer.
- Online: One player hosts a server, and the other connects using the provided IP address.
- Toggle game rules like En Passant, Castling, and Pawn Promotion via the settings menu.
- Switch between movement options (click or drag-and-drop).
├── rootfolder/ # Resources for the game
├── pieces/ # Piece images and themes
├── sounds/ # Sound files
├── stockfish/ # Stockfish engine
├── the_board.py # Core game logic
├── the_menu.py # Settings menu and rules
├── server.py # Online multiplayer server logic
├── client.py # Online multiplayer client logic
To play in online multiplayer mode:
- Open three terminal instances.
- Navigate to the root folder in all instances:
cd "C:\Users\to\root\folder"
- Start the server:
python server.py
- Run
the_menu.pyon the other two instances to start the game for both players.
- The end game screen (e.g., checkmate, stalemate, or draw) is incomplete.
- It should display results with options to replay or quit.
- Not fully implemented in all movement functions.
- En Passant capture is not added to the score tally.
- Add a delay between player and bot turns.
- Fix click-based movement for bots, as it occasionally behaves unpredictably.
- Consider implementing a custom AI algorithm instead of Stockfish for more flexibility.
- Implement graceful handling of disconnects, including notifications and reconnect options.
- Add user feedback (e.g., loading screens) during connection setup.
- Provide retry options for failed connections.
- Add a pawn promotion dialog for players to choose the desired piece.
- Handle all end game conditions properly, including notifications for checkmate, stalemate, or draw.
- Improve error handling and stability for online multiplayer.
- Include a timed chess clock for competitive play.
- Enhance visual feedback for invalid moves and rule violations.
- Prompt players for their names at the start to personalize the experience.
- Introduce additional themes for boards and pieces.
- The game utilizes Stockfish's API for AI decision-making.
- Players can set a time limit for the bot’s moves, affecting its depth of calculation and performance.
Follow these steps to download and install Stockfish:
- Visit the Stockfish downloads page.
- Extract the ZIP file and locate the
stockfishorstockfish.exebinary. - Place the binary in the
stockfish/folder. - Test Stockfish in the terminal:
Use commands like
cd path/to/stockfish ./stockfishposition startposandgoto interact with the engine.
- Timed Chess Clock: Add a timer for each player.
- Spectator Mode: Allow others to watch live games.
- Enhanced AI: Implement a custom chess AI.
- Expanded Themes: Offer more customization for board and piece designs.
License: MIT License
- Comprehensive Chess Rules: Eddie's YouTube Playlist
- Live Demo: Gameplay Video