A fully functional, interactive chess game built using Python's Tkinter library. This GUI-based application allows two players to play classic chess with move validation, check/checkmate detection, and visual indicators for selected pieces and legal moves.
- π Start Screen with stylized UI and chess piece decorations
- β Drag-free click-to-move piece mechanics
- β Highlights legal moves in green
- π¨ Highlights the king in red when in check
- β Check and Checkmate detection
- π Restart game or return to main menu
- π‘ Suggested move logic (code retained, not exposed in UI)
- π± Responsive Tkinter UI optimized for 600x700 window
- Make sure Python 3 is installed.
- Clone this repository or download
chess.py.
git clone https://github.com/your-username/python-chess-tk.git
cd python-chess-tkRun the game:
python chess.pyπ How to Play Click on a chess piece to select it.
Legal destination squares will highlight in green.
Click on one of the highlighted squares to make your move.
When a king is in check, the square turns red.
The game ends when a checkmate occurs.
Use the top control buttons to return to the menu, start a new game, or exit.
π¦ Dependencies Python standard library only
tkinter (included with most Python distributions)
π Code Structure ChessApplication: Manages UI navigation between start screen and the game
ChessGUI: Handles board creation, rendering, move validation, check/checkmate detection, and turn logic
Internal utility methods manage:
Piece movement rules
Legal move generation
King safety checks
Stalemate and checkmate detection
π§ Game Logic Highlights Accurate handling of movement rules for all standard chess pieces
King position tracking and attack path analysis
Visual feedback for all game states
Prevents illegal moves that expose the king to check
Detects endgames including checkmate and stalemate
π License This project is licensed under the MIT License. You are free to use, modify, and distribute it as you like.
π€ Contributing Contributions, bug reports, and feature requests are welcome. Feel free to fork the repository and open a pull request.