This is a Python script for a basic chess game with a timer functionality using the Tkinter library and the chess library.
Features:
- Standard chess gameplay with valid moves and piece captures.
- Timer for each player, configurable during game setup.
- Visual representation of the chessboard with colored squares and piece symbols.
- Highlights valid moves for the selected piece.
- Handles pawn promotion with user selection for the promoted piece.
- Allows proposing a draw and displays a message box for the outcome of the game (checkmate, stalemate, insufficient material, or time loss).
- Option to restart the game after it ends.
Requirements:
- Python 3.x
- Tkinter library (usually comes pre-installed with Python)
- chess library:
pip install chess
Running the Game:
- Save the script as
chess!.py
. (As chess is name of one of python libraries too.) - Open a terminal or command prompt and navigate to the directory where you saved the script.
- Run the script using the following command:
python chess!.py
Gameplay:
- The game starts with a welcome screen where you can enter player names and a timer limit(Optional as default names are player 1 and 2 and time is 5 min).
- Click the "Start Game" button to begin the game.
- The board will be displayed, with the current player's turn indicated.
- Click on a piece to select it.
- Valid moves for the selected piece will be highlighted in green.
- Click on a highlighted square to move the piece.
- The timer will continue to run for the current player.
- If a player runs out of time, the other player wins.
- You can propose a draw by clicking the "Propose Draw" button.
Additional Notes:
- This is a basic implementation and lacks features like castling, en passant, and advanced AI opponents.
- The code is well-commented and structured for readability.
- There is no model for chess pieces instered they have names like BK(Black Knight),WQ(White Queen) etc.
I Hope You Enjoy It.