0% found this document useful (0 votes)
10 views26 pages

Pyp Mic

The document outlines a micro project on a Chess Game developed by a group of three students from the Government Polytechnic Jalgaon as part of their Computer Engineering course for the academic year 2023-2024. It includes details on project objectives, methodology, a weekly progress report, and an evaluation sheet, along with the source code and a description of the game's features. The project aims to provide an interactive chess experience using Python, focusing on user engagement and AI challenges.

Uploaded by

jpb16007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views26 pages

Pyp Mic

The document outlines a micro project on a Chess Game developed by a group of three students from the Government Polytechnic Jalgaon as part of their Computer Engineering course for the academic year 2023-2024. It includes details on project objectives, methodology, a weekly progress report, and an evaluation sheet, along with the source code and a description of the game's features. The project aims to provide an interactive chess experience using Python, focusing on user engagement and AI challenges.

Uploaded by

jpb16007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

MAHARASTRA STATE BOARD TECHNICAL

EDUCATION
GOVERNMENT POLYTECHNIC JALGAON
(0018)

Program name and code : Computer Engineering

Course name : Programming With Python

Course code : [22616]

Academic year : 2023-2024

Semester : Sixth
A MICRO PROJECT ON

Report on Chess Game.

Submitted by the group of 3 students

Sr. Roll Name of student Enrolment No. Seat No.


No. No.
1 5 Saurabh Bapusaheb Bagul 2100180215 377601
2 6 Jitesh Kishor Barhate 2100180216 377602
3 42 Lokesh Jitendra Dhangar 2100180265 377642

Project Guide: Amol Chaudhari sir


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION

Certificate

This is to certify that Saurab Bagul, Jitesh Barhate, Lokesh Dhangar Roll No.5,6,42
of 6th Semester of Diploma in Computer Engineering of Government Polytechnic,
Jalgaon (Code:0018) has completed the Micro Project satisfactorily in the subject
Programming With Python(22616) for the Academic Year 2023-2024 as prescribed
in the curriculum.

Place: Jalgaon enrolment no:2100180215,16,65.

Subject Teacher Head of Department Principal

Seal of institution
GOVTERNMENT POLYTECHNIC JALGAON

-SUBMISSION

We are Saurabh Bagul, Jitesh Barhate, Lokesh Dhangar students of 6th Semester
of the Programme Computer Engineering humbly submit that we have completed
from time to time the Micro-Project work as described in this report by y our own skills
and study in academic year 2023-2024 as per instructions and guidance Amol
Chaudhari Sir that following students were associated with me for this work,
however, quantum of my contribution has been approved by the Lecturer.
And that I have not copied the report on its any appreciable part from any other
literature in contravention of the academic ethics.

Date: Signature of Student


05 –

06 –

42 -
WEEKLY PROGRESS REPORT

SR.NO. WEEK ACTIVITY PERFORMED SIGN OF GUIDE DATE

1 Discussion and finalization of topic

2 First Preparation and submission of

Week Abstract
3 Literature Review

4 Collection of Data

5 Collection of Data

Second
6 Week Discussion and outline of Content

7 Formulation of Content

8 Editing and proof Reading of


Content
9 Compilation of Report and
Presentation
Third
10 Seminar
Week

11 Viva voce

12 Final submission of Micro Project

Sign of student sign of faculty


Evaluation Sheet for the Micro Project
Name of Student: S.B.B., J.K.B., L.J.D.
Enrolment No. :2100180215,2100180216,2100180265.
Semester: Sixth
Course Title: Programming With Python
Code: 22616

Title of the Micro-Project: Chess Game.

Micro-Project Evaluation Sheet

Marks out of 6 for


performance in Marks out of 4 for
Roll No. Name of student group activity performance in
oral/presentation Total out of 10
(D5 Coi.8)
(D5 Coi.9)

05. Saurabh Bagul

06. Jitesh Barhate

42. Lokesh Dhangar


Acknowledgement

This Micro project would not have been possible without considerable
guidance and support. So, we would like to acknowledge those who have
enable us to complete this project.
Firstly, we would like to thank our project guide, Amol Chaudhari sirfor
providing the guideline with continuous advice and feedback throughout the
duration of finishing this project. We also thank to Dr P. M. Patil
(principal of Government Polytechnic Jalgaon) for providing us the
opportunity to embark on this project.
Secondly, we would also like to thank all other staff members of Computer
department that we may called upon for assistance since the genesis of this
project their opinion and suggestion have helped us in a realizing these
projects.
Also not to be forgotten, we would like to thank all our friends with the
report valuable opinion and sharing ideas during the process of this project.
Finally, we would like to thank our families for their understanding,
encouragement and support towards the completion of project.

Thank you so much.


INDEX

1. Abstract

2. Introduction

3. Source Code

4. Outputs

5. Conclusion

6. Refernces
PART A: A MICROPROJECT PROPOSAL
CHESS GAME

1.0 :Aims/Benefits of the Micro-Project :

To study and to prepare report on Chess


game

6.0 : Course Outcome Addressed :

• To study about the Python and Machine Learning.


• Make an Project on Smart Attendance System.
• To solve real world problems.

• Able to understand the Python and Machine learning language .

3.0: Methodology :
Firstly, we have study python language packages then
we have analysed attributes, packages of Machine
Learning . We gain the knowledge about that system
with the working of it. We have gained knowledge
about Various packages like face- recognition, numpy
etc in python.
4.0 : Action plan
Sr Detail of Activity Plan Start Plan finish Name of responsible
No. Date Date team members
1 Discussion and
finalization of topic 05 :
2 Preparation and Saurabh
submission of Abstract Bagul
3 Literature Review
06: Jitesh
4 Collection of Data Barhate

42: Lokesh
5 Collection of Data Dhangar
6 Discussion and outline
of Content
7 Formulation ofcontent

8 Editing and Readingof


Content
9 Compilation of report
and presentation

10 Seminar

11 Viva voce

5.0 Resources Used :

Sr Name of Resource Specifications Quantit


No. Material y

1 PC Laptop with processor 1


i5,8GBRAM
2 Operating Windows 10 Home 1
System Single
Language
3 Software Editor :- Pycharm 1
PART B: A MICROPROJECT REPORT

CHESS GAME

1.0 Rationale
Prepare a report on Chess Game .
2.0 Aim/Benefits of the micro-project
Aim of the project is preparing report on Chess Game
3.0 Course Outcome Addressed
a) To study about the Python and Machine Learning.
b) Make an Project on Chess Game.
c) To solve real world problems.

d) Able to understand the Python and Machine learning language .


Abstract

In this Python project, we aim to develop a chess game implementing fundamental


chess rules and functionalities. The game will be designed to provide an interactive
platform for users to play against each other or against an AI opponent. Key features
of the game include move validation, check and checkmate detection, piece movement,
capturing, and promotion. The user interface will be designed for ease of interaction,
allowing players to make moves through simple mouse clicks or keyboard inputs.
Additionally, the project will focus on optimizing the AI algorithms to provide
challenging gameplay for users at various skill levels. Through this implementation,
users will have the opportunity to engage in strategic and intellectually stimulating
chess matches within the Python environment.
Introduction

Chess, often hailed as the "game of kings," stands as a testament to human intellect
and strategic prowess. With its origins dating back over a millennium, chess has
evolved into a universal language, transcending borders and cultures. In the modern
era, the fusion of technology and tradition has brought chess to digital platforms,
making it accessible to players worldwide. This Python project seeks to immerse users
in the captivating realm of chess, offering a digital rendition of this age-old classic.
Through intuitive interfaces and intricate algorithms, players will engage in battles of
wit and strategy, whether challenging a computer opponent or competing against
fellow enthusiasts online. By delving into this project, users embark on a journey
where every move becomes a calculated step towards victory, further perpetuating the
timeless allure of chess in the digital age.

This Python-based chess project serves as a gateway to this rich tradition, offering an
immersive and interactive experience for players of all levels. By harnessing the power
of Python's versatility and simplicity, this endeavor aims to deliver a user-friendly
interface coupled with robust gameplay mechanics. Whether one seeks to sharpen their
skills against a sophisticated AI adversary or engage in friendly competitions with
peers, this project promises to provide a fulfilling and intellectually stimulating chess
experience.
Source Code

# Importing Modules
import pygame

# Initialising pygame module


pygame.init()

# Setting Width and height of the Chess Game screen


WIDTH = 800
HEIGHT = 800

screen = pygame.display.set_mode([WIDTH, HEIGHT])


pygame.display.set_caption('Two-Player Chess Game')

font = pygame.font.Font('freesansbold.ttf', 20)


medium_font = pygame.font.Font('freesansbold.ttf', 40)
big_font = pygame.font.Font('freesansbold.ttf', 50)

timer = pygame.time.Clock()
fps = 60

# game variables and images


white_pieces = ['rook', 'knight', 'bishop', 'king', 'queen', 'bishop', 'knight', 'rook',
'pawn', 'pawn', 'pawn', 'pawn', 'pawn', 'pawn', 'pawn', 'pawn']
white_locations = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0),
(0, 1), (1, 1), (2, 1), (3, 1), (4, 1), (5, 1), (6, 1), (7, 1)]
black_pieces = ['rook', 'knight', 'bishop', 'king', 'queen', 'bishop', 'knight', 'rook',
'pawn', 'pawn', 'pawn', 'pawn', 'pawn', 'pawn', 'pawn', 'pawn']
black_locations = [(0, 7), (1, 7), (2, 7), (3, 7), (4, 7), (5, 7), (6, 7), (7, 7),
(0, 6), (1, 6), (2, 6), (3, 6), (4, 6), (5, 6), (6, 6), (7, 6)]

captured_pieces_white = []
captured_pieces_black = []

# 0 - whites turn no selection: 1-whites turn piece selected: 2- black turn no selection, 3 - black turn piece selected
turn_step = 0
selection = 100
valid_moves = []

# load in game piece images (queen, king, rook, bishop, knight, pawn) x 2
black_queen = pygame.image.load('D:\\python\\pygame\\images\\black_queen.png')
black_queen = pygame.transform.scale(black_queen, (80, 80))
black_queen_small = pygame.transform.scale(black_queen, (45, 45))
black_king = pygame.image.load('D:\python\pygame\images\\black_king.png')
black_king = pygame.transform.scale(black_king, (80, 80))
black_king_small = pygame.transform.scale(black_king, (45, 45))
black_rook = pygame.image.load('D:\python\pygame\images\\black_rook.png')
black_rook = pygame.transform.scale(black_rook, (80, 80))
black_rook_small = pygame.transform.scale(black_rook, (45, 45))
black_bishop = pygame.image.load('D:\python\pygame\images\\black_bishop.png')
black_bishop = pygame.transform.scale(black_bishop, (80, 80))
black_bishop_small = pygame.transform.scale(black_bishop, (45, 45))
black_knight = pygame.image.load('D:\python\pygame\images\\black_knight.png')
black_knight = pygame.transform.scale(black_knight, (80, 80))
black_knight_small = pygame.transform.scale(black_knight, (45, 45))
black_pawn = pygame.image.load('D:\python\pygame\images\\black_pawn.png')
black_pawn = pygame.transform.scale(black_pawn, (65, 65))
black_pawn_small = pygame.transform.scale(black_pawn, (45, 45))
white_queen = pygame.image.load('D:\python\pygame\images\white_queen.png')
white_queen = pygame.transform.scale(white_queen, (80, 80))
white_queen_small = pygame.transform.scale(white_queen, (45, 45))
white_king = pygame.image.load('D:\python\pygame\images\white_king.png')
white_king = pygame.transform.scale(white_king, (80, 80))
white_king_small = pygame.transform.scale(white_king, (45, 45))
white_rook = pygame.image.load('D:\python\pygame\images\white_rook.png')
white_rook = pygame.transform.scale(white_rook, (80, 80))
white_rook_small = pygame.transform.scale(white_rook, (45, 45))
white_bishop = pygame.image.load('D:\python\pygame\images\white_bishop.png')
white_bishop = pygame.transform.scale(white_bishop, (80, 80))
white_bishop_small = pygame.transform.scale(white_bishop, (45, 45))
white_knight = pygame.image.load('D:\python\pygame\images\white_knight.png')
white_knight = pygame.transform.scale(white_knight, (80, 80))
white_knight_small = pygame.transform.scale(white_knight, (45, 45))
white_pawn = pygame.image.load('D:\python\pygame\images\white_pawn.png')
white_pawn = pygame.transform.scale(white_pawn, (65, 65))
white_pawn_small = pygame.transform.scale(white_pawn, (45, 45))

white_images = [white_pawn, white_queen, white_king,


white_knight, white_rook, white_bishop]
small_white_images = [white_pawn_small, white_queen_small, white_king_small, white_knight_small,
white_rook_small, white_bishop_small]

black_images = [black_pawn, black_queen, black_king,


black_knight, black_rook, black_bishop]
small_black_images = [black_pawn_small, black_queen_small, black_king_small, black_knight_small,
black_rook_small, black_bishop_small]

piece_list = ['pawn', 'queen', 'king', 'knight', 'rook', 'bishop']

# check variables/ flashing counter


counter = 0
winner = ''
game_over = False

# draw main game board


def draw_board():
for i in range(32):
column = i % 4
row = i // 4
if row % 2 == 0:
pygame.draw.rect(screen, 'light gray', [
600 - (column * 200), row * 100, 100, 100])
else:
pygame.draw.rect(screen, 'light gray', [
700 - (column * 200), row * 100, 100, 100])
pygame.draw.rect(screen, 'gray', [0, 800, WIDTH, 100])
pygame.draw.rect(screen, 'gold', [0, 800, WIDTH, 100], 5)
pygame.draw.rect(screen, 'gold', [800, 0, 200, HEIGHT], 5)
status_text = ['White: Select a Piece to Move!', 'White: Select a Destination!',
'Black: Select a Piece to Move!', 'Black: Select a Destination!']
screen.blit(big_font.render(
status_text[turn_step], True, 'black'), (20, 820))
for i in range(9):
pygame.draw.line(screen, 'black', (0, 100 * i), (800, 100 * i), 2)
pygame.draw.line(screen, 'black', (100 * i, 0), (100 * i, 800), 2)
screen.blit(medium_font.render('FORFEIT', True, 'black'), (810, 830))

# draw pieces onto board


def draw_pieces():
for i in range(len(white_pieces)):
index = piece_list.index(white_pieces[i])
if white_pieces[i] == 'pawn':
screen.blit(
white_pawn, (white_locations[i][0] * 100 + 22, white_locations[i][1] * 100 + 30))
else:
screen.blit(white_images[index], (white_locations[i]
[0] * 100 + 10, white_locations[i][1] * 100 + 10))
if turn_step < 2:
if selection == i:
pygame.draw.rect(screen, 'red', [white_locations[i][0] * 100 + 1, white_locations[i][1] * 100 + 1,
100, 100], 2)

for i in range(len(black_pieces)):
index = piece_list.index(black_pieces[i])
if black_pieces[i] == 'pawn':
screen.blit(
black_pawn, (black_locations[i][0] * 100 + 22, black_locations[i][1] * 100 + 30))
else:
screen.blit(black_images[index], (black_locations[i]
[0] * 100 + 10, black_locations[i][1] * 100 + 10))
if turn_step >= 2:
if selection == i:
pygame.draw.rect(screen, 'blue', [black_locations[i][0] * 100 + 1, black_locations[i][1] * 100 + 1,
100, 100], 2)

# function to check all pieces valid options on board


def check_options(pieces, locations, turn):
moves_list = []
all_moves_list = []
for i in range((len(pieces))):
location = locations[i]
piece = pieces[i]
if piece == 'pawn':
moves_list = check_pawn(location, turn)
elif piece == 'rook':
moves_list = check_rook(location, turn)
elif piece == 'knight':
moves_list = check_knight(location, turn)
elif piece == 'bishop':
moves_list = check_bishop(location, turn)
elif piece == 'queen':
moves_list = check_queen(location, turn)
elif piece == 'king':
moves_list = check_king(location, turn)
all_moves_list.append(moves_list)
return all_moves_list

# check king valid moves


def check_king(position, color):
moves_list = []
if color == 'white':
enemies_list = black_locations
friends_list = white_locations
else:
friends_list = black_locations
enemies_list = white_locations
# 8 squares to check for kings, they can go one square any direction
targets = [(1, 0), (1, 1), (1, -1), (-1, 0),
(-1, 1), (-1, -1), (0, 1), (0, -1)]
for i in range(8):
target = (position[0] + targets[i][0], position[1] + targets[i][1])
if target not in friends_list and 0 <= target[0] <= 7 and 0 <= target[1] <= 7:
moves_list.append(target)
return moves_list

# check queen valid moves


def check_queen(position, color):
moves_list = check_bishop(position, color)
second_list = check_rook(position, color)
for i in range(len(second_list)):
moves_list.append(second_list[i])
return moves_list

# check bishop moves


def check_bishop(position, color):
moves_list = []
if color == 'white':
enemies_list = black_locations
friends_list = white_locations
else:
friends_list = black_locations
enemies_list = white_locations
for i in range(4): # up-right, up-left, down-right, down-left
path = True
chain = 1
if i == 0:
x=1
y = -1
elif i == 1:
x = -1
y = -1
elif i == 2:
x=1
y=1
else:
x = -1
y=1
while path:
if (position[0] + (chain * x), position[1] + (chain * y)) not in friends_list and \
0 <= position[0] + (chain * x) <= 7 and 0 <= position[1] + (chain * y) <= 7:
moves_list.append(
(position[0] + (chain * x), position[1] + (chain * y)))
if (position[0] + (chain * x), position[1] + (chain * y)) in enemies_list:
path = False
chain += 1
else:
path = False
return moves_list

# check rook moves


def check_rook(position, color):
moves_list = []
if color == 'white':
enemies_list = black_locations
friends_list = white_locations
else:
friends_list = black_locations
enemies_list = white_locations
for i in range(4): # down, up, right, left
path = True
chain = 1
if i == 0:
x=0
y=1
elif i == 1:
x=0
y = -1
elif i == 2:
x=1
y=0
else:
x = -1
y=0
while path:
if (position[0] + (chain * x), position[1] + (chain * y)) not in friends_list and \
0 <= position[0] + (chain * x) <= 7 and 0 <= position[1] + (chain * y) <= 7:
moves_list.append(
(position[0] + (chain * x), position[1] + (chain * y)))
if (position[0] + (chain * x), position[1] + (chain * y)) in enemies_list:
path = False
chain += 1
else:
path = False
return moves_list

# check valid pawn moves


def check_pawn(position, color):
moves_list = []
if color == 'white':
if (position[0], position[1] + 1) not in white_locations and \
(position[0], position[1] + 1) not in black_locations and position[1] < 7:
moves_list.append((position[0], position[1] + 1))
if (position[0], position[1] + 2) not in white_locations and \
(position[0], position[1] + 2) not in black_locations and position[1] == 1:
moves_list.append((position[0], position[1] + 2))
if (position[0] + 1, position[1] + 1) in black_locations:
moves_list.append((position[0] + 1, position[1] + 1))
if (position[0] - 1, position[1] + 1) in black_locations:
moves_list.append((position[0] - 1, position[1] + 1))
else:
if (position[0], position[1] - 1) not in white_locations and \
(position[0], position[1] - 1) not in black_locations and position[1] > 0:
moves_list.append((position[0], position[1] - 1))
if (position[0], position[1] - 2) not in white_locations and \
(position[0], position[1] - 2) not in black_locations and position[1] == 6:
moves_list.append((position[0], position[1] - 2))
if (position[0] + 1, position[1] - 1) in white_locations:
moves_list.append((position[0] + 1, position[1] - 1))
if (position[0] - 1, position[1] - 1) in white_locations:
moves_list.append((position[0] - 1, position[1] - 1))
return moves_list

# check valid knight moves


def check_knight(position, color):
moves_list = []
if color == 'white':
enemies_list = black_locations
friends_list = white_locations
else:
friends_list = black_locations
enemies_list = white_locations
# 8 squares to check for knights, they can go two squares in one direction and one in another
targets = [(1, 2), (1, -2), (2, 1), (2, -1),
(-1, 2), (-1, -2), (-2, 1), (-2, -1)]
for i in range(8):
target = (position[0] + targets[i][0], position[1] + targets[i][1])
if target not in friends_list and 0 <= target[0] <= 7 and 0 <= target[1] <= 7:
moves_list.append(target)
return moves_list

# check for valid moves for just selected piece


def check_valid_moves():
if turn_step < 2:
options_list = white_options
else:
options_list = black_options
valid_options = options_list[selection]
return valid_options

# draw valid moves on screen


def draw_valid(moves):
if turn_step < 2:
color = 'red'
else:
color = 'blue'
for i in range(len(moves)):
pygame.draw.circle(
screen, color, (moves[i][0] * 100 + 50, moves[i][1] * 100 + 50), 5)

# draw captured pieces on side of screen


def draw_captured():
for i in range(len(captured_pieces_white)):
captured_piece = captured_pieces_white[i]
index = piece_list.index(captured_piece)
screen.blit(small_black_images[index], (825, 5 + 50 * i))
for i in range(len(captured_pieces_black)):
captured_piece = captured_pieces_black[i]
index = piece_list.index(captured_piece)
screen.blit(small_white_images[index], (925, 5 + 50 * i))

# draw a flashing square around king if in check


def draw_check():
if turn_step < 2:
if 'king' in white_pieces:
king_index = white_pieces.index('king')
king_location = white_locations[king_index]
for i in range(len(black_options)):
if king_location in black_options[i]:
if counter < 15:
pygame.draw.rect(screen, 'dark red', [white_locations[king_index][0] * 100 + 1,
white_locations[king_index][1] * 100 + 1, 100, 100], 5)
else:
if 'king' in black_pieces:
king_index = black_pieces.index('king')
king_location = black_locations[king_index]
for i in range(len(white_options)):
if king_location in white_options[i]:
if counter < 15:
pygame.draw.rect(screen, 'dark blue', [black_locations[king_index][0] * 100 + 1,
black_locations[king_index][1] * 100 + 1, 100, 100], 5)

def draw_game_over():
pygame.draw.rect(screen, 'black', [200, 200, 400, 70])
screen.blit(font.render(
f'{winner} won the game!', True, 'white'), (210, 210))
screen.blit(font.render(f'Press ENTER to Restart!',
True, 'white'), (210, 240))

# main game loop


black_options = check_options(black_pieces, black_locations, 'black')
white_options = check_options(white_pieces, white_locations, 'white')
run = True
while run:
timer.tick(fps)
if counter < 30:
counter += 1
else:
counter = 0
screen.fill('dark gray')
draw_board()
draw_pieces()
draw_captured()
draw_check()
if selection != 100:
valid_moves = check_valid_moves()
draw_valid(valid_moves)
# event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1 and not game_over:
x_coord = event.pos[0] // 100
y_coord = event.pos[1] // 100
click_coords = (x_coord, y_coord)
if turn_step <= 1:
if click_coords == (8, 8) or click_coords == (9, 8):
winner = 'black'
if click_coords in white_locations:
selection = white_locations.index(click_coords)
if turn_step == 0:
turn_step = 1
if click_coords in valid_moves and selection != 100:
white_locations[selection] = click_coords
if click_coords in black_locations:
black_piece = black_locations.index(click_coords)
captured_pieces_white.append(black_pieces[black_piece])
if black_pieces[black_piece] == 'king':
winner = 'white'
black_pieces.pop(black_piece)
black_locations.pop(black_piece)
black_options = check_options(
black_pieces, black_locations, 'black')
white_options = check_options(
white_pieces, white_locations, 'white')
turn_step = 2
selection = 100
valid_moves = []
if turn_step > 1:
if click_coords == (8, 8) or click_coords == (9, 8):
winner = 'white'
if click_coords in black_locations:
selection = black_locations.index(click_coords)
if turn_step == 2:
turn_step = 3
if click_coords in valid_moves and selection != 100:
black_locations[selection] = click_coords
if click_coords in white_locations:
white_piece = white_locations.index(click_coords)
captured_pieces_black.append(white_pieces[white_piece])
if white_pieces[white_piece] == 'king':
winner = 'black'
white_pieces.pop(white_piece)
white_locations.pop(white_piece)
black_options = check_options(
black_pieces, black_locations, 'black')
white_options = check_options(
white_pieces, white_locations, 'white')
turn_step = 0
selection = 100
valid_moves = []
if event.type == pygame.KEYDOWN and game_over:
if event.key == pygame.K_RETURN:
game_over = False
winner = ''
white_pieces = ['rook', 'knight', 'bishop', 'king', 'queen', 'bishop', 'knight', 'rook',
'pawn', 'pawn', 'pawn', 'pawn', 'pawn', 'pawn', 'pawn', 'pawn']
white_locations = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0),
(0, 1), (1, 1), (2, 1), (3, 1), (4, 1), (5, 1), (6, 1), (7, 1)]
black_pieces = ['rook', 'knight', 'bishop', 'king', 'queen', 'bishop', 'knight', 'rook',
'pawn', 'pawn', 'pawn', 'pawn', 'pawn', 'pawn', 'pawn', 'pawn']
black_locations = [(0, 7), (1, 7), (2, 7), (3, 7), (4, 7), (5, 7), (6, 7), (7, 7),
(0, 6), (1, 6), (2, 6), (3, 6), (4, 6), (5, 6), (6, 6), (7, 6)]
captured_pieces_white = []
captured_pieces_black = []
turn_step = 0
selection = 100
valid_moves = []
black_options = check_options(
black_pieces, black_locations, 'black')
white_options = check_options(
white_pieces, white_locations, 'white')

if winner != '':
game_over = True
draw_game_over()

pygame.display.flip()

pygame.quit()
Outputs

Chessboard
Player 1 Move :
Player 2 Move:
Conclusion

In conclusion, the development of this Python-based chess game represents more than
just the recreation of a timeless pastime in a digital format. It symbolizes the fusion of
tradition and technology, where centuries-old strategies meet cutting-edge
programming techniques. Through meticulous design and implementation, this project
has provided users with an immersive and engaging platform to explore the depths of
chess strategy, whether they are beginners or seasoned veterans.

As players navigate through the intricacies of piece movement, strategic positioning,


and tactical foresight, they not only hone their skills but also embark on a journey of
intellectual growth and discovery. Beyond the confines of the game board, this project
serves as a testament to the collaborative spirit of the open-source community, where
enthusiasts and developers come together to contribute to a shared passion.

References

• https://scholar.google.com

• https://docs.opencv.org/master/index.html

• https://www.pygame.com

You might also like