Skip to content

komal-mahale2004/Chess-Game-project-using-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

2 Commits
ย 
ย 
ย 
ย 

Repository files navigation

Chess-Game-project-using-python

overview

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.

image

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

#โ–ถ๏ธ Usage Run the chess game with:

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.


๐Ÿ”น Sample Python Code (Simplified Version โ€“ Tkinter)

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()

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published