Chess-Game-project-using-python
The Chess Game is a Python-based application that allows two players to play chess interactively. It uses object-oriented programming to define pieces, rules, and moves, while providing a GUI board built with Tkinter/Pygame.
This project is a great way to learn game development, GUI programming, and algorithm design in Python.
#๐ Features ๐ฎ Play two-player chess on a GUI board. โ Enforces legal chess moves (pawn, rook, knight, bishop, queen, king). ๐ Detects check & checkmate conditions. ๐ฅ๏ธ Graphical interface using Tkinter/Pygame. ๐ Beginner-friendly example of OOP + game logic. ๐ ๏ธ Tech Stack #Language: Python Libraries: Tkinter / Pygame Concepts: Object-Oriented Programming, Game Loops, Event Handling ๐ Project Structure project/ โโโ chess.py # Main game logic โโโ pieces.py # Chess piece classes (Pawn, Rook, etc.) โโโ gui.py # GUI code (Tkinter/Pygame) โโโ assets/ # Piece images (PNG) โโโ README.md
#
python chess.py
Select and move pieces using mouse clicks.
Game enforces legal moves and alternating turns.
๐ธ Example Screenshot
(Insert screenshot of chessboard here)
๐ฎ Future Enhancements
๐ค Add AI opponent using Minimax algorithm.
โฑ๏ธ Add timer & move history log.
๐ Enable online multiplayer mode.
๐จ Improve UI with better graphics.
๐ License
This project is licensed under the MIT License โ free to use and modify.
import tkinter as tk
# Board dimensions
BOARD_SIZE = 8
TILE_SIZE = 60
root = tk.Tk()
root.title("Chess Game")
canvas = tk.Canvas(root, width=BOARD_SIZE*TILE_SIZE, height=BOARD_SIZE*TILE_SIZE)
canvas.pack()
# Draw chess board
for row in range(BOARD_SIZE):
for col in range(BOARD_SIZE):
color = "white" if (row+col) % 2 == 0 else "gray"
canvas.create_rectangle(col*TILE_SIZE, row*TILE_SIZE,
(col+1)*TILE_SIZE, (row+1)*TILE_SIZE, fill=color)
# Place sample pieces (use text instead of images for simplicity)
pieces = {"R": (0,0), "N": (0,1), "B": (0,2), "Q": (0,3), "K": (0,4)}
for p, (row,col) in pieces.items():
canvas.create_text(col*TILE_SIZE+30, row*TILE_SIZE+30, text=p, font=("Arial", 24))
root.mainloop()