Report
Report
By
SATHYABAMA
INSTITUTE OF SCIENCE AND
TECHNOLOGY(DEEMED TO BE
UNIVERSITY)
March 2021
i
SATHYABAMA
INSTITUTE OF SCIENCE ANDTECHNOLOGY
(DEEMED TO BE UNIVERSITY)
Accredited with “A” grade by NAAC I 12B Status by UGC I Approved by
AICTE
Jeppiaar Nagar, Rajiv Gandhi Salai, Chennai – 600 119
www.sathyabama.ac.in
BONAFIDE CERTIFICATE
This is to certify that this Project Report is the bonafide work of MANI SURYA TEJA
(37110369) who carried out the project entitled “CHESS GAME” under my
supervision from November 2020 to March 2021.
Internal Guide
Dr. B. BHARATHI, M.E., Ph.D.,
I MANI SURYA TEJA KOTA (37110369) hereby declare that the Project Report entitled
“CHESS GAME” is done by me under the guidance of Dr. B. BHARATHI, M.E., Ph.D.,
Department of Computer Science and Engineering at Sathyabama Institute of Science and
Technology is submitted in partial fulfilment of the requirements for the award of Bachelor
of Engineering degree in Computer Science and Engineering.
DATE:
iii
ACKNOWLEDGEMENT
I convey my thanks to Dr. T. Sasikala, M.E., Ph.D., Dean, School of Computing, Dr. L.
Lakshmanan M.E., Ph.D., and Dr.S.Vigneshwari M.E., Ph.D., Heads of the
Department of Computer Science and Engineering for providing me necessary support
and details at the right time during the progressive reviews.
I would like to express my sincere and deep sense of gratitude to my Project Guide Dr.
B. BHARATHI, M.E., Ph.D.,, for her valuable guidance, suggestions and constant
encouragement paved way for the successful completion of my project work.
I wish to express my thanks to all Teaching and Non-teaching staff members of the
Department of Computer Science and Engineering who were helpful in many ways
for the completion of the project.
iv
ABSTRACT
Based upon the game chess. Here the requirements are quiet simple, just a
python compiler is enough to program this CHESS game. I used a recent latest version
of python compiler (python 3.7.2). This game contains as generally a chess game has,
all pieces are named in the format of piece color. The „random‟ package is used in this
game, which is used to randomized our chances or player turns to play. We have to
enter the inputs to play the game are 1. piece name 2. initial x, y values
3. destination x, y values.
So the key of the game is purely based upon the co-ordinates of x y. And firstly
this game is k-sensitive. And a single mistake of entering piece name will not let us to do
it again. And the output is presented by printable named function which also represents
the chess board along with the value update. And the rules of each piece is the only time
taking and also hardest part the game, cause for example piece „rook‟ ‟have to move
only either the up-side, down-side, right-side or left-side, so in the co-ordinates of x and y
either x value should vary or y value should vary. And here the problem is if in between
the initial and destination point if any same side of the player‟s piece contain then castle
should stop in possible front of the piece. So that every step is must and should counted
to check whether any piece contains or not. And the further information is detailed in the
introduction part of the game.
v
TABLE OF CONTENTS
ABSTRACT v
1. CHAPTER 1: INTRODUCTION
1.1 INTRODUCTION 1
1.2 RESEARCH AND SIGNIFICANCE 1
REFERENCES 16
APPENDIX
1. PAPER ACCEPTANCE MAIL 17
2. PLAGARISM REPORT 18
3. SOURCE CODE 19
4. PAPER ACCEPTANCE 31
LIST OF FIGURES
viii
CHAPTER 1
INTRODUCTION
1.1 INTRODUCTION
Overview: Based upon the game chess. Here the requirements are quiet simple,
just a python compiler is enough to program this CHESS game. I used a recent latest
version of python compiler (python 3.7.2). This game contains as generally a chess
game has, all pieces are named in the format of (Piece name.colour). The „random‟
package is used in this game, which is used to randomized our chances or player turns
to play. We have to enter the inputs to play the game are 1. piece name 2. initial x, y
values 3. destination x, y values.
So the key of the game is purely based upon the co-ordinates of x y. And firstly
this game is k-sensitive. And a single mistake of entering piece name will not let us to do
it again. And the output is presented by printable named function which also represents
the chess board along with the value update. And the rules of each piece is the only time
taking and also hardest part the game, cause for example piece „rook‟ ‟have to move
only either the up-side, down-side, right-side or left-side, so in the co-ordinates of x and y
either x value should vary or y value should vary. And here the problem is if in between
the initial and destination point if any same side of the player‟s piece contain then castle
should stop in possible front of the piece. So that every step is must and should counted
to check whether any piece contains or not. And the further information is detailed in the
introduction part of the game.
The main aim of this application I.e. to create a own and customizable chess
engine, which is easy to understand and code. And also to provide a user friendly
interface for the user while playing.
1
CHAPTER 2
LITERATURE SURVEY
Literature survey is that the most significant step in code development method.
Before developing the tool it's necessary to see the time issue, economy and company
strength. Once these items are happy, then consecutive step is to see that OS and
language may be used for developing the tool.
Once the programmers begin building the tool the programmers need ton of
external support. This support are obtained from senior programmers, from book or
from websites.
Before building the system the on prime of thought unit taken into thought for
developing the planned system. the main half of the project development sector
considers and totally survey all the desired desires for developing the project. for each
project Literature survey is that the most significant sector in code development
method.
Before developing the tools and therefore the associated coming up with it's
necessary to work out and survey the time issue, resource demand, man power,
economy, and company strength.
Once these items area unit glad and absolutely surveyed, then consecutive
step is to see concerning the software package specifications within the individual
system like what form of software system the project would need, and what area unit
all the required software package area unit required to proceed with consecutive step
like developing the tools, and also the associated operations.
2
CHAPTER 3
3.1 AIM
The objective of this project is to create a own Chess engine which is user friendly and
also to make user comfortable. And this project is a two player game. And prediction
for game winner is to display for every move.
3.2 SCOPE
3
CHAPTER 4
This system is proposed with certain features which makes user to feel comfortable.
The proposed system is a engine which can detect whether the present move is right
or wrong.
Checks the each and every move is going to be the part of winning prediction of the
player.
Notifications like player moves and taken opponent‟s chess piece is displayed.
Illegal moves are not considered and given chance to make a perfect move.
Understandable code for everyone because of co-ordinates geometry concept.
This proposed software runs effectively on a computing system that has the
minimum requirements. Undertaking all the equipment necessities are not satisfied but
rather exist in their systems administration between the user‟s machines already. So,
the main need is to introduce appropriate equipment for the product. The requirements
are split into two categories, namely:
1. Windows 10
2. Pycharm and Modules like random, pygame are needed to be imported.
4
4.2.2 HARDWARE REQUIREMENTS
The basic hardware required to run the program are:
1. Hard disk of 5 GB
2. System memory (RAM) of 512 MB
3. I3 processor-based computer or higher.
In the present scenario, python has its module called chess which can do all the
operations on the chess moves. But graphically its not. And it is the most used module
for the chess game and for chess study purpose.
5
CHAPTER 5
SOFTWARE DEVELOPMENT METHODOLOGY
6
CHESS game is done by based on 2-Dimensional array. I took a[8][8] array to have
8*8 square box or to represent the board. And placing is done by referencing a normal
chess board, pieces like castle, bishop, knight, king, queen and pawn are their entire
different rules. And win flag is applied to declare the winner. Finally who kills the king
he‟ll be the winner of the game and announced at last.
KEYS:
CASTLE - The movement of the castle must be either in straight line or horizontal
Line like [x1][y1] is to move. so,if the difference is dx or dy movement
must be [x1+dx][y1] or [x1][y1+dy].
KNIGHT - The movement of the knight must be in shape of „L‟ in any direction and
be like [x1][y1] is to move. So, general movement is [x1+2][y1+1] or
[x1+2][y1-1] or [x1+2][y1+1] or [x1-2][y1+1] or [x1-2][y1-1] or [x1+2][y1-1]
or [x1-2][y1-1].
BISHOP - The movement of the bishop must be in diagonal in any direction and be
like [x1][y1] is to move. So, general movement if dx and dy are equal
[x1+dx][y1+dy].
QUEEN - The movement of queen is a combination of castle and bishop. So, the
general movement if dx and dy are the difference, be like [x1+dx][y1] or
[x1][y1+dy] or [x1+dx][y1+dy].
KING - The movement of king must have to move one step in any direction so,
move must be in [x1+1][y] or [x1][y+1] or [x1+1][y-1] or [x1-1][y-1]
or [x1+1][y+1] or [x1-1][y+1]
7
CHAPTER 6
MODULE DESCRIPTION:
8
➢ Winner deaclaration module
Game Intro Module:
It is important to know the players information to specify them during the game. So in
this module players information is taken and saved for future purpose. And also to
change the chances of players to play.
9
Step Validation module:
This module provides signal whether the move is valid/legal or not. And in this module
there are multiple signals given for the input move. There are totally 4 types of signals
/ flags . They are :-
1. Signal 0:
This signal is for to indicate the input move / step is not valid / legal. And
also if the player unwantedly selects the opponent‟s chess piece it generates a signal
0 and displays the message that “wrong move”.
10
2. Signal 1:
This signal is for the chess piece whether it can move to its destination with
no interaction of any chess piece in its way. If it can made the destination, then signal
is generated and message is generated that it made a safe move.
11
3. Signal 11:
This signal is for chess piece whether the player1 piece captured or taken
the opponents piece. If this condition is true then system generates a message like “
[player1 piece] killed [player2 piece]”.
12
4. Signal 22:
This signal is for chess piece whether the player1 piece is perfectly captured
the opponent‟s king. If it is done it returns a signal 22. Finally winner declaration will
be done and game will be over.
And after completion of checking these validations it goes to the chess board for the
next step updation of the chess board. So that it can move chess piece in the code
and display over the window.
13
Game Updation Module:
This module is used update the chess board which is used to display current state of
board for every move. There will be done two things.
This module is used to fetch the game all the time to check whether the opponent‟s
king is been captured or not. If yes, then game is closed and displays the message
like “[winning player‟s name] win”
14
CHAPTER 7
CONCLUSION
By checking all the possible cases to run the chess engine. This project running
successfully without any flaws. And also can be done in advanced way.
It is a chess game with more benefits. Firstly, its more benefitable for the ones
who wants and tries to study the code and logic behind the code. And its GUI
programming of the pygame is more flexible than the “Ktinker module” for gaming
interface.
15
REFERENCES
https://youtu.be/FfWpgLFMI7w (link)
16
APPENDIX
1. PAPER ACCEPTANCE
17
2. PLAGIARISM REPORT
18
SOURCE CODE
import pygame as p
s1=[]
s1.append(input('ENTER YOUR NAME PLAYER 1'))
s1.append(input('ENTER YOUR NAME PLAYER 2'))
W = [0]
B = [0]
p.init()
h = w = 512
s = p.display.set_mode((512, 512))
p.display.set_caption("M-S-T's ChessEngine")
l=p.image.load('chess-board.png')
p.display.set_icon(l)
c = [p.Color('white'), p.Color('grey')]
sq = h//8
pi = ['bR', 'bN', 'bB', 'bQ', 'bK', 'bP', 'wR', 'wK', 'wB', 'wQ', 'wN',
'wP']
b_board = [['bR', 'bN', 'bB', 'bQ', 'bK', 'bB', 'bN', 'bR'],
['bP', 'bP', 'bP', 'bP', 'bP', 'bP', 'bP', 'bP'],
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
['wP', 'wP', 'wP', 'wP', 'wP', 'wP', 'wP', 'wP'],
['wR', 'wN', 'wB', 'wK', 'wQ', 'wB', 'wN', 'wR']]
pics = {}
for i in pi:
pics[i] = p.transform.scale(p.image.load(i+'.png'), (64, 64))
def chess_board():
for i in range(8):
for j in range(8):
c1 = c[(i+j) % 2]
p.draw.rect(s, c1, p.Rect(j*sq, i*sq, sq, sq))
for i in range(8):
for j in range(8):
if b_board[i][j] != ' ':
s.blit(pics[b_board[i][j]], p.Rect(j*sq, i*sq, 64, 64))
f = 1
prev = [-1, -1]
19
def validation(a, b):
m = b_board[a[0]][a[1]]
if m[0] == 'b':
if m[1] == 'P':
if a[0] == 1 and b[0] == 3 and a[1] == b[1] and
b_board[a[0]+1][a[1]] == ' ' and b_board[b[0]][b[1]] == ' ':
return 1
elif a[0]+1 == b[0] and a[1] == b[1] and b_board[b[0]][b[1]] ==
' ':
return 1
elif a[0]+1 == b[0] and (a[1]+1 == b[1] or a[1]-1 == b[1]) and
b_board[b[0]][b[1]][0] == 'w':
if b_board[b[0]][b[1]][1] == 'K':
return 22
return 11
return 0
20
return 11
elif b_board[b[0]][b[1]] == ' ':
return 1
else:
if abs(a[0]-b[0])==1 or abs(a[1]-b[1])==1:
if b_board[b[0]][b[1]] == 'wK':
return 22
elif b_board[b[0]][b[1]][0] == 'w':
return 11
elif b_board[b[0]][b[1]] == ' ':
return 1
return 0
return 0
elif m[1]=='N':
d1 = a[0]-b[0]
d2 = a[1]-b[1]
if (d1==1 and d2==2) or (d1==2 and d2==1) or (d1==-2 and d2==1)
or (d1==2 and d2==-1) or (d1==-1 and d2==-2) or (d1==-2 and d2==-1) or
(d1==-1 and d2==2) or (d1==1 and d2==-2):
if b_board[b[0]][b[1]]==' ':
return 1
elif b_board[b[0]][b[1]]=='wK':
return 22
elif b_board[b[0]][b[1]][0]=='w':
return 11
return 0
elif m[1]=='B':
d1 = (b[0]-a[0])
d2 = (b[1]-a[1])
c=0
f=0
while (abs(d1)==abs(d2))!=0:
if abs(d1)==abs(d2) and c<abs(d1) and d1>0 and d2>0 and
b_board[a[0]+(c+1)][a[1]+(c+1)]==' ' and (f==0 or f==1):
c+=1
f=1
elif abs(d1)==abs(d2) and c<abs(d1) and d1<0 and d2>0 and
b_board[a[0]-(c+1)][a[1]+(c+1)]==' ' and (f==0 or f==2):
c+=1
f=2
elif abs(d1)==abs(d2) and c<abs(d1) and d1>0 and d2<0 and
b_board[a[0]+(c+1)][a[1]-(c+1)]==' ' and (f==0 or f==3):
c+=1
f=3
elif abs(d1)==abs(d2) and c<abs(d1) and d1<0 and d2<0 and
b_board[a[0]-(c+1)][a[1]-(c+1)]==' ' and (f==0 or f==4):
c+=1
f=4
elif abs(d1)==1:
if b_board[b[0]][b[1]]==' ':
return 1
elif b_board[b[0]][b[1]]=='wK':
return 22
elif b_board[b[0]][b[1]][0]=='w':
return 11
21
else:
return 0
else:
break
if f>0:
if b_board[b[0]][b[1]] == ' ':
return 1
elif b_board[b[0]][b[1]] == 'wK':
return 22
elif b_board[b[0]][b[1]][0] == 'w':
return 11
return 0
if m[1]=='Q':
d1=(b[0]-a[0])
d2=(b[1]-a[1])
if abs(d1)==abs(d2):
c = 0
f = 0
while (abs(d1) == abs(d2)) != 0:
if abs(d1) == abs(d2) and c < abs(d1) and d1 > 0 and d2
> 0 and b_board[a[0] + (c + 1)][a[1] + (c + 1)] == ' ' and (f == 0 or f ==
1):
c += 1
print(a, b, c)
f = 1
elif abs(d1) == abs(d2) and c < abs(d1) and d1 < 0 and
d2 > 0 and b_board[a[0] - (c + 1)][
a[1] + (c + 1)] == ' ' and (f == 0 or f == 2):
c += 1
f = 2
elif abs(d1) == abs(d2) and c < abs(d1) and d1 > 0 and
d2 < 0 and b_board[a[0] + (c + 1)][
a[1] - (c + 1)] == ' ' and (f == 0 or f == 3):
c += 1
f = 3
elif abs(d1) == abs(d2) and c < abs(d1) and d1 < 0 and
d2 < 0 and b_board[a[0] - (c + 1)][
a[1] - (c + 1)] == ' ' and (f == 0 or f == 4):
c += 1
f = 4
elif abs(d1) == 1:
if b_board[b[0]][b[1]] == ' ':
return 1
elif b_board[b[0]][b[1]] == 'wK':
return 22
elif b_board[b[0]][b[1]][0] == 'w':
return 11
else:
return 0
else:
break
if f > 0:
if b_board[b[0]][b[1]] == ' ':
return 1
elif b_board[b[0]][b[1]] == 'wK':
22
return 22
elif b_board[b[0]][b[1]][0] == 'w':
return 11
elif d1==0 or d2==0:
f = 0
c = [0, 0, 0, 0]
while a[1] != b[1] or a[0] != b[0]:
if a[0] + (c[0] + 1) < b[0] and b_board[a[0] + (c[0] +
1)][a[1]] == ' ' and \
b_board[a[0] + (c[0] + 1)][a[1]][0] != 'b' and
(f == 0 or f == 1):
c[0] += 1
f = 1
elif a[0] + (c[1] - 1) > b[0] and b_board[a[0] + (c[1]
- 1)][a[1]] == ' ' and \
b_board[a[0] + (c[1] - 1)][a[1]][0] != 'b' and
(f == 0 or f == 2):
f = 2
c[1] -= 1
elif a[1] + (c[2] + 1) < b[1] and b_board[a[0]][a[1] +
(c[2] + 1)] == ' ' and \
b_board[a[0]][a[1] + (c[2] + 1)][0] != 'b' and
(f == 0 or f == 3):
f = 3
c[2] += 1
elif a[1] + (c[3] - 1) > b[1] and b_board[a[0]][a[1] +
(c[3] - 1)] == ' ' and \
b_board[a[0]][a[1] + (c[3] - 1)][0] != 'b' and
(f == 0 or f == 4):
f = 4
c[3] -= 1
else:
if f <= 2 and (a[0] + (c[f - 1] + 1) == b[0] or
a[0] + (c[f - 1] - 1) == b[0]) and a[1] == b[1]:
if b_board[b[0]][b[1]] == 'wK':
return 22
elif b_board[b[0]][b[1]][0] == 'w':
return 11
elif b_board[b[0]][b[1]] == ' ':
return 1
elif f > 2 and a[0] == b[0] and (
a[1] + (c[f - 1] + 1) == b[1] or a[1] +
(c[f - 1] - 1) == b[1]):
if b_board[b[0]][b[1]] == 'wK':
return 22
elif b_board[b[0]][b[1]][0] == 'w':
return 11
elif b_board[b[0]][b[1]] == ' ':
return 1
else:
if abs(a[0] - b[0]) == 1 or abs(a[1] - b[1]) ==
1:
if b_board[b[0]][b[1]] == 'wK':
return 22
elif b_board[b[0]][b[1]][0] == 'w':
return 1
23
return 0
return 0
elif m[1]=='K':
d1=a[0]-b[0]
d2=a[1]-b[1]
if (abs(d1)<2 and abs(d2)<2) and (a[0]!=b[0] or a[1]!=b[1]):
if b_board[b[0]][b[1]]=='wK':
return 22
elif b_board[b[0]][b[1]][0]=='w':
return 11
elif b_board[b[0]][b[1]]==' ':
return 1
return 0
if m[0]=='w':
if m[1]=='P':
if a[0]==6 and b[0]==4 and a[1]==b[1] and b_board[a[0]-1][a[1]]=='
' and b_board[b[0]][b[1]]==' ':
return 1
elif a[0]-1==b[0] and a[1]==b[1] and b_board[b[0]][b[1]]==' ':
return 1
elif a[0]-1==b[0] and (a[1]-1==b[1] or a[1]+1==b[1]) and
b_board[b[0]][b[1]][0]=='b':
if b_board[b[0]][b[1]][1]=='K':
return 22
return 11
return 0
24
return 22
elif b_board[b[0]][b[1]][0] == 'b':
return 11
elif b_board[b[0]][b[1]]==' ':
return 1
elif f>2 and a[0]==b[0] and (a[1]+(c[f-1]+1)==b[1] or
a[1]+(c[f-1]-1) == b[1]):
if b_board[b[0]][b[1]] == 'bK':
return 22
elif b_board[b[0]][b[1]][0] == 'w':
return 11
elif b_board[b[0]][b[1]] == ' ':
return 1
else:
if abs(a[0]-b[0])==1 or abs(a[1]-b[1])==1:
if b_board[b[0]][b[1]] == 'bK':
return 22
elif b_board[b[0]][b[1]][0] == 'b':
return 11
elif b_board[b[0]][b[1]] == ' ':
return 1
return 0
return 0
elif m[1]=='N':
d1 = a[0]-b[0]
d2 = a[1]-b[1]
if (d1==1 and d2==2) or (d1==2 and d2==1) or (d1==-2 and d2==1) or
(d1==2 and d2==-1) or (d1==-1 and d2==-2) or (d1==-2 and d2==-1) or (d1==-1
and d2==2) or (d1==1 and d2==-2):
if b_board[b[0]][b[1]]==' ':
return 1
elif b_board[b[0]][b[1]]=='wK':
return 22
elif b_board[b[0]][b[1]][0]=='w':
return 11
return 0
elif m[1]=='B':
d1 = (b[0]-a[0])
d2 = (b[1]-a[1])
c=0
f=0
while (abs(d1)==abs(d2))!=0:
if abs(d1)==abs(d2) and c<abs(d1) and d1>0 and d2>0 and
b_board[a[0]+(c+1)][a[1]+(c+1)]==' ' and (f==0 or f==1):
c+=1
print(a,b,c)
f=1
elif abs(d1)==abs(d2) and c<abs(d1) and d1<0 and d2>0 and
b_board[a[0]-(c+1)][a[1]+(c+1)]==' ' and (f==0 or f==2):
c+=1
f=2
elif abs(d1)==abs(d2) and c<abs(d1) and d1>0 and d2<0 and
b_board[a[0]+(c+1)][a[1]-(c+1)]==' ' and (f==0 or f==3):
25
c+=1
f=3
elif abs(d1)==abs(d2) and c<abs(d1) and d1<0 and d2<0 and
b_board[a[0]-(c+1)][a[1]-(c+1)]==' ' and (f==0 or f==4):
c+=1
f=4
elif abs(d1)==1:
if b_board[b[0]][b[1]]==' ':
return 1
elif b_board[b[0]][b[1]]=='bK':
return 22
elif b_board[b[0]][b[1]][0]=='b':
return 11
else:
return 0
else:
break
if f>0:
if b_board[b[0]][b[1]] == ' ':
return 1
elif b_board[b[0]][b[1]] == 'bK':
return 22
elif b_board[b[0]][b[1]][0] == 'b':
return 11
return 0
elif m[1]=='Q':
d1 = (b[0] - a[0])
d2 = (b[1] - a[1])
if abs(d1) == abs(d2):
c = 0
f = 0
while (abs(d1) == abs(d2)) != 0:
if abs(d1) == abs(d2) and c < abs(d1) and d1 > 0 and d2 >
0 and b_board[a[0] + (c + 1)][
a[1] + (c + 1)] == ' ' and (f == 0 or f == 1):
c += 1
print(a, b, c)
f = 1
elif abs(d1) == abs(d2) and c < abs(d1) and d1 < 0 and d2
> 0 and b_board[a[0] - (c + 1)][
a[1] + (c + 1)] == ' ' and (f == 0 or f == 2):
c += 1
f = 2
elif abs(d1) == abs(d2) and c < abs(d1) and d1 > 0 and d2
< 0 and b_board[a[0] + (c + 1)][
a[1] - (c + 1)] == ' ' and (f == 0 or f == 3):
c += 1
f = 3
elif abs(d1) == abs(d2) and c < abs(d1) and d1 < 0 and d2
< 0 and b_board[a[0] - (c + 1)][
a[1] - (c + 1)] == ' ' and (f == 0 or f == 4):
c += 1
f = 4
elif abs(d1) == 1:
if b_board[b[0]][b[1]] == ' ':
return 1
26
elif b_board[b[0]][b[1]] == 'bK':
return 22
elif b_board[b[0]][b[1]][0] == 'b':
return 11
else:
return 0
else:
break
if f > 0:
if b_board[b[0]][b[1]] == ' ':
return 1
elif b_board[b[0]][b[1]] == 'bK':
return 22
elif b_board[b[0]][b[1]][0] == 'b':
return 11
if a[0] == b[0] or a[1] == b[1]:
f=0
c=[0,0,0,0]
while a[1]!=b[1] or a[0]!=b[0]:
if a[0]+(c[0]+1)<b[0] and b_board[a[0]+(c[0]+1)][a[1]]=='
' and b_board[a[0]+(c[0]+1)][a[1]][0]!='w' and (f==0 or f==1):
c[0]+= 1
f = 1
elif a[0]+(c[1]-1)>b[0] and b_board[a[0]+(c[1]-
1)][a[1]]==' ' and b_board[a[0]+(c[1]-1)][a[1]][0]!='w' and (f==0 or f==2):
f = 2
c[1]-=1
elif a[1]+(c[2]+1)<b[1] and
b_board[a[0]][a[1]+(c[2]+1)]==' ' and b_board[a[0]][a[1]+(c[2]+1)][0]!='w'
and (f==0 or f==3):
f = 3
c[2]+=1
elif a[1]+(c[3]-1)>b[1] and b_board[a[0]][a[1]+(c[3]-
1)]==' ' and b_board[a[0]][a[1]+(c[3]-1)][0]!='w' and (f==0 or f==4):
f = 4
c[3]-=1
else:
if f<=2 and (a[0]+(c[f-1]+1)==b[0] or a[0]+(c[f-1]-
1)==b[0]) and a[1]==b[1]:
print(1)
if b_board[b[0]][b[1]] == 'bK':
return 22
elif b_board[b[0]][b[1]][0] == 'b':
return 11
elif b_board[b[0]][b[1]]==' ':
return 1
elif f>2 and a[0]==b[0] and (a[1]+(c[f-1]+1)==b[1] or
a[1]+(c[f-1]-1) == b[1]):
print(2)
if b_board[b[0]][b[1]] == 'bK':
return 22
elif b_board[b[0]][b[1]][0] == 'w':
return 11
elif b_board[b[0]][b[1]] == ' ':
return 1
else:
if abs(a[0]-b[0])==1 or abs(a[1]-b[1])==1:
if b_board[b[0]][b[1]] == 'bK':
27
return 22
elif b_board[b[0]][b[1]][0] == 'b':
return 11
elif b_board[b[0]][b[1]] == ' ':
return 1
return 0
print(a,b,c,f)
return 0
elif m[1]=='K':
d1=a[0]-b[0]
d2=a[1]-b[1]
if (abs(d1)<2 and abs(d2)<2) and (a[0]!=b[0] or a[1]!=b[1]):
print('king w',1)
if b_board[b[0]][b[1]]=='bK':
return 22
elif b_board[b[0]][b[1]][0]=='b':
return 11
elif b_board[b[0]][b[1]]==' ':
return 1
return 0
return 0
def Prob_to_win():
print()
print()
if W[0] > B[0]:
print('Looks like game winning is favourable to ' + s1[0])
elif W[0] < B[0]:
print('Looks like game winning is favourable to ' + s1[1])
else:
print('Looks like game id going to be tie')
print()
print()
print()
if f==2:
for e in p.event.get():
if e.type == p.QUIT:
f = 0
elif e.type == p.MOUSEBUTTONDOWN:
loc = p.mouse.get_pos()
y=loc[0]//64
x=loc[1]//64
elif [x, y] != prev and prev != [-1, -1] and v >= 11:
if v == 11:
29
print(b_board[prev[0]][prev[1]]+' killed
'+b_board[x][y])
b_board[x][y] = b_board[prev[0]][prev[1]]
b_board[prev[0]][prev[1]] = ' '
f = 1
prev = [-1, -1]
v=-1
B[0]+=1
Prob_to_win()
print(s1[0]+' turn (whites)')
else:
print(s1[1]+' wins')
f = 0
elif v==0:
prev=[-1,-1]
elif [x, y]!=prev and prev == [-1, -1] and
b_board[x][y][0]=='b':
print(s1[1]+' picked '+b_board[x][y])
prev[0] = x
prev[1] = y
else:
prev=[-1,-1]
print('wrong move')
chess_board()
p.display.flip()
30
PAPER ACCEPTANCE
CHESS GAME
Mani Surya Teja Kota1
1
B.E. Computer science and Engineering, Sathyabama Institute of Science and Technology,
Chennai, India
ABSTRACT- “CHESS GAME” is a game based project on Chess engine. Generally, chess is a two player
game where each player strives to win on their individual sides. And making with user friendly interface is
the ’s main theme. And implementing the maximum rules for individual chess piece by mathematical way
using co-ordinates concept in geometry.
Keywords: - Python Programming, Prediction, Problem Solving, Pygame, GUI.
31
4. MODULE DESCRIPTION:
Project Modules:
➢ Game Intro Module
➢ User Input module
➢ Step Validation module
➢ Game Updation module
➢ Winner deaclaration module
3. SYSTEM ARCHITECTURE:
32
valid/legal or not. And in this module there are
32
multiple signals given for the input move. There are This signal is for chess piece whether the
totally 4 types of signals / flags . They are :- player1 piece captured or taken the opponents piece.
If this condition is true then system generates a
5. Signal 0: message like “ [player1 piece] killed [player2 piece]”.
8. Signal 22:
This signal is for the chess piece whether it can 7. Signal 11:
move to its destination with no interaction of any chess
piece in its way. If it can made the destination, then signal
is generated and message is generated that it made a safe
move.
33
is done it returns a signal 22. Finally winner declaration will be
done and game will be over.
34
board. So that it can move chess piece in the code and
display over the window.
5. RESULTS:
By checking all the possible cases to run the chess
engine. This project running successfully without any
flaws. And also can be done in advanced way.
6. CONCLUSION:
is a chess game with more benefits. Firstly, its more
benefitable for the ones who wants and tries to study the
code and logic behind the code. And its GUI
programming of the pygame is more flexible than the
“Ktinker module” for gaming interface.
REFERENCES:
https://youtu.be/FfWpgLFMI7w (link)
35