Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 35

ACKNOWLEDGEMENT

We express our deep sense of gratitude to our honorable and beloved


Founder President Dr. N. M. VEERAIYAN, our President Dr. SAVEETHA
RAJESH, our Director Dr. S. Rajesh and other management members for
providing the infrastructure needed.
We express our wholehearted gratitude to our principal, Dr. N.
DURAIPANDIAN, for his wholehearted encouragement in completing this
project.
We convey our thanks to Dr. G. NAGAPPAN, Professor and Head of the
Department of Computer Science and Engineering, Saveetha Engineering
College, for his kind support and for providing necessary facilities to carry out
the project work.
We would like to express our sincere thanks and deep sense of gratitude to
our Supervisor Dr. ANITHA JULIAN, Professor, Department of Computer
Science and Engineering, Saveetha Engineering College and Project
Coordinator, Mrs G.ABINAYA, Assistant Professor, Department of Computer
Science and Engineering, Saveetha Engineering College, for her valuable
guidance, suggestions and constant encouragement that paved the way for the
successful completion of the project work and for providing us necessary
support and details at the right time and during the progressivereviews.
We owe our thanks to all the members of our college, faculty, staff and
technicians for their kind and valuable cooperation during the course of the
project. We are pleased to acknowledge our sincere thanks to our beloved
parents, friends and well-wishers who encouraged us to complete this project
successfully.

i
ABSTRACT

Game development now a days is a developing field where many different kinds of
games are been developed which helps the other users who are playing them to get
stress free, and to get relaxed but these games are been developed in many different
kinds of software and languages which are complicated but using the python makes
the development easy. The python language makes the development of any game easy
and the problems can be shortlisted easily and can be rectified and keeping the track
on the code is also easy. Chess which do play between two players on a board is
intellectual and mental game, it has its own rules of play which help to enhance and
improve the mental and intellectual activities of the player, and this game has a huge
amount of players around the all world they have strongly interested to have play it.
This document deals with the fully computerized Chess Game, first, the game
computerizes for two player to do play chess according all the valid rules of the chess
on computer. Secondly, for making the game more interesting that will make users to
direct do play against computer, computer intellectual force is added. There are three
recognized phases in a chess game: the opening, where piece development and
control of the center predominate; the middlegame, where maneuvering in defense
and attack against the opponent’s king or weaknesses occurs; and the endgame,
where, generally after several piece exchanges, pawn promotion becomes the
dominant theme.

ii
TABLE OF CONTENTS

Chapter Number Title Page Number

ABSTRACT Ⅳ

1. INTRODUCTION 1
1.1 OVERVIEW OF THE PROJECT 1
1.2 SCOPE AND OBJECTIVE 2
2. LITERATURE SURVEY 3
2.1 INTRODUCTION 3
2.2 LITERATURE SURVEY 4
3. SYSTEM DESIGN 8
3.1 ALGORITHM – MINIMAX 8
3.1.1 Minimax Algorithm diagram 9
3.2 ADVANTAGES OF ALGORITHM 9
3.3 LIMITATIONS OF ALGORITHM 9
3.4 ARCHITECTURE DIAGRAM 10
3.5 HARDWARE REQUIRED 10
3.6 SOFTWARE REQUIRED 10
4. MODULES 11
4.1 INTRODUCTION 11
4.2 LEGAL MOVES 11
4.3 CHECK MATE 11
4.4 DRAW MATCH 12
4.5 UML DIAGRAM 13
5. IMPLEMENTATION AND ANALYSIS 14
5.1 PYTHON LIBRARY 14
5.1.1 Pygame 14
5.1.2 Sys 15
5.1.3 Os 15
iii
5.2 DATA 16
5.3 FEASIBILITY STUDY 16
5.3.1 Economical feasibility 17
5.3.2 Techinical feasibility 17
5.3.3 Social feasibility 17
5.4 SOFTWARE DESCRIPTION 18
5.5 SAMPLE CODING 18
5.5.1 Main.py 19
5.5.2 Game.py 22
5.6 SAMPLE OUTPUTS 25
6. CONCLUSION 28
REFERENCES 29

iv
LIST OF FIGURES

3.1 Minimax Algorithm diagram. 9

3.2 Architecture Diagram. 10

4.1 UML diagram 13

5.1 Basic design of the chess board. 25

5.2 When the pieces are selected. 26

5.3 When a piece is moved. 26

5.4 When there is a check. 27

5.5 When the pawn is replaced by queen. 27

v
CHAPTER 1

INTRODUCTION

1.1 OVERVIEW OF THE PROJECT

The overview of the project is that the Chess Game was created using Python
module that contains multiple platforms that utilize the maximum capability for
programming. The game is played in a simple windowed interface that comes with
a sprites and backgrounds images. The player can play the game via Mouse, you
only need to use the Left Mouse Button to move a chess piece by dragging it in a
correct position such as(Pawn can move two turn forward in first move and eat
enemy piece diagonally, Horse can only move in L shape position, Bishop can only
move diagonally, Queen can move anywhere diagonally or straight, king can only
move one block away).

The game is very hard and challenging you need to think twice before you
move. White piece always go first, if you are a white make a winnable first move to
increase you chance of winning.

1
1.2 SCOPE AND

OBJECTIVE SCOPE

The scope of this project is to play chess game with friends and to have fun
and interactive conversations that helps to develop our IQ, and our creative
thinking.

Chess theory is the body of knowledge accumulated over the history of the
game. It usually divides the game into three stages: the opening, the middle game,
and the endgame. Opening theory embodies the first few moves of a game.

OBJECTIVE
The Chess Game was created using Python module that contains multiple
platforms that utilize the maximum capability for programming. The game is
played in a simple windowed interface that comes with a sprites and backgrounds
images. This application is for educational purpose only, you are free to modify it
as you fit your needs. The Chess Game is a simple arcade style game where your
goal is to strategize your move in order to win.

2
CHAPTER 2
LITERATURE SURVEY

2.1 INTRODUCTION

A literature survey or a literature review in a project report is that section


which shows various analysis and research made in the field of your interest and
the results already published, taking into account the various parameters of the
project and the extent of project. Once the programmers start building the tool
programmers need a lot of external support. This support can be obtained from
senior programmers, books or from the websites. It is the most important part
ofyour report as it gives you a direction in the area of your research. It helps you
set a goal for your analysis
- thus giving you your problem of statement.Literature survey is the most
important sector in the software development process. Before developing the tools
and the associated designing it is necessary to determine the survey the time factor,
resource requirement, manpower, economy, and company strength.
A literature survey is a summary of previous research on a topic. It includes
books and other scholarly articles. Nonetheless, a literature survey involves
reading, analyzing, and interpreting the body of literature. The main purpose is to
understand the works and ideas of different authors (what’s already written).
Therefore, the topic should be of relevance.

3
2.2 LITERATURE SURVEY
1. Murray Campbell et al contributed in the making of this chess engine which
was attempted twice because the first time it lost to the chess grandmaster
Garry Kasparov in 1996 but later went on to defeat him in 1997. It was the
first chess machine to defeat a grandmaster in tournament play. It uses a
single chip move generator. Deep Thought 1 and Deep thought 2 were
intermediate stepping stones to the Deep Blue, but Deep Thought 2 was
played in a lot of public events from 1991-1995. Deep Blue I, which was
initially defeated by Kasparov, made it clear that it had certain shortcomings
which had to be fulfilled. Thus, a new chip was designed which went from
6400 features to 8000 features. Basically, the chip combines a software
search in C language as well as a hardware search on the silicone chip and
generates the best move set possible. It implements the null window alpha
beta algorithm and even without pruning, it is a very effective search.

2. Fogel et al made this engine, where the flaws of machine learning are
overcome. Since credit assignment system has its flaws, the evolutionary
system is more efficient. The evolutionary algorithm uses three artificial
neural networks to evaluate the worth of potential positions in the chessboard
that are alternate. All three players start with neural networks and play in
random variation to evaluate the fittest of them all through the quality of the
moves. Then, the fittest players generate the off spring for the next
generation. This algorithm is very useful as the evolution of a high-level
chess program suggests broader applications to problem solving and also
gives us the possibility to attempt solving problems to which known
solutions do not exist.

3. Tong Lai Yu et al used the single threaded chess engine Beowolf in this
project. Platform independent SDL libraries are used inorder to make it more
4
efficient so as to incorporate graphics and other media into the game.
Beowulf searches a game tree using the Negamax Search algorithm, which is
a simply a variation of the minimax search that accounts the zero sum game.
The game tree is simplified by Alpha-Beta pruning. The 2D graphics and
sound is added with the help of SDL libraries that are written in C/C++. The
3D graphics are implemented with the help of open source tools such as
Blender 3D. Thus, this paper establishes the fact that a chess engine with
amazing graphics, or any other grid game can be created with the help of
open source tools.

4. D. M. Raif, et al In this paper, the main objective was to make the game more
aesthetically appealing by the addition of art constructed by ceramic material.
Cartoons are considered the best way to deliver a message across to the
game’s audience and this paper converts the usual chess pieces into cartoon
ceramic chess pieces for more visual appeal. Every 3D character is a set of
2D images used to construct it according to the planned model and altering its
movements. Thus, each piece is given its own shape, size, texture, movement
and personality to give the game of chess an edge over the other engines.

5. Liqun Zhang et al introduce the program of Surakarta chess battle platform in


computer game is a network program. It is played on a server by both sides
on the client side and the game starts after both sides login successfully. The
server has to be a special server since the game itself judges who’s winning
and human intervention only proves to slow down the engine. Unlike regular
chess, this version of chess follows the rule of moving pieces one square
vertically or diagonally to a position that is not occupied by another piece
unless it is a capture. Also, the board is represented in a different way. The
Surakarta chess is the most efficient way to hold large machine games which

5
is a great way to compare which machine works the best when it comes to a
game of chess.

6. Omid E. David et al put forward the idea that unlike the conventional chess
engines, genetic algorithm can be used to skip the brute force and actually
improve the AI to such a potential that it can surpass a human at the game.
The algorithm starts with a population, and with each generation, the fitness
improves, which improves the chances of a computer winning against a
human. In the initial stages of chess engines, only 1-ply searches were
possible, but due to the algorithm’s evolutionary nature, now it is possible to
make tens of plies searches in a tournament game. This is tested out in this
paper with the help of chess as well as checkers.

7. Nathaporn Karnjanapoomi et al in this paper brings out the possibility of


throwing away the orthodox idea of a two player chess games and allowing 3
players to play in the same game. Any player that captures another payer’s
King, is declared a winner in this game. Thus, this game not only gives an
opposing edge, but also creates the possibility of cooperation of two players
to defeat the third one. This is implemented by the use of Nondominated
Adversarial Search algorithm which makes it necessary for the player to
select the quantity of good moves over quality of moves.

8. Wu Gui et al [11] in this paper, has tried to improve the game search
algorithm to make it more practical for the game engines created now. This
Chinese chess engine solves the frequently faced problems in the search tree.
The board is represented as a 16*16 matrix, thus solving it as a 256 byte
system. This helps the system evaluate the board in one dimensional arrays
quickly and efficiently. Multiple search algorithms are then compared and
evaluated to see
6
which one works thebest and is practical to be implemented on all kinds of
host systems. The rules of Chinese chess are used for these experiments.

9. Diego Real and Alan Blair [10] made the Duchess chess engine work with
efficiency. In this paper, the duchess chess engine is explained which allows
upto six players in each game and also adds an additional coin of the
‘Duchess’, which can perform the Bishop and Knight’s moves. This engine
also adds one additional player i.e. the computer, for any additional help that
is required as well as to replace a player if they lose the game. This engine
was initially impossible to run because of the lack of efficient technology but
is now possible with the help of the Tree Strap Algorithm.The tree search is
sped up by searching cumulatively, i.e., only searching the board where the
changes have occurred. This helps the game run fast despite having six
players simultaneously

7
CHAPTER 3

SYSTEM

DESIGN

3.1 ALGORITHM – MINIMAX

Minimax is a type of backtracking algorithm. The Minimax algorithm finds


an optimal move to make decisions in game theory. Minimax algorithm takes into
consideration that the opponent is also playing optimally, which makes it useful for
two-player games such as checker, chess, Tic-tac-toe, go and many others. In
general, when two human beings play, they must make the decision at each move
with all the possible moves, and then chose anyone which he thinks is the best
move. The same is with the Minimax algorithm too, but here the decision, to make
a move is taken using a backtracking approach. To do this it selects two players one
is the min, and the other is max, the goal of min player is to pick the minimum
value, and on the other hand, the goal of max is to pick the maximum value.

It is a decision-making algorithm used in game theory. It considers two


players min and max, and min always picks up a minimum value score from game
and max always picks up maximum value score. The value for each game move is
decided based on some heuristics.

8
3.1 Minimax Algorithm diagram.

3.2 ADVANTAGES OF MINIMAX ALGORITHM

 A thorough assessment of the search space is performed.


 Decision making in AI is easily possible.
 New and smart machines are developed with this algorithm.

3.3 LIMITATIONS OF MINIMAX ALGORITHM

 It compares with each data in the terminal nodes, for example, in L2N3, the
maximum value is -4 between -4, -∞ and -6. But after assigning -4, it will
cross-check with -6 and answer will be -4, which makes it slow. Our example
just has two nodes, but in the case of Tic-tac-toe, we have 8,7,6… moves
respectively at each node. And checking at each node with each value is
time- consuming.
 The complexity of increases for some high-level games such as chess and go,
which has a number of pieces to move and a number of places to move it to.

9
Which makes it very complex. And somehow if we create trees, it results in
the very large branched tree.

3.4 ARCHITECTURE DIAGRAM

3.2 Architecture diagram

3.5 HARDWARE REQUIREMENTS


 RAM : 4GB.
 STORAGE : 500GB.
 CPU : 2GHz or faster.
 ARCHITECTURE : 32-bit or 64-bit.

3.6 SYSTEM REQUIREMENT


 OPREATING SYSTEM – WINDOWS 10 or Above.
 CODING LANGUAGE – PYTHON.
 SOFTWARE – VISUAL STUDIO CODE.

10
CHAPTER 4
MODULES

4.1 INTRODUCTION
The chess module is a pure Python chess library with move generation, move
validation and support for common formats. We can play chess with it. It will help
us to move the king queen, pawn, bishops and knights. We need to know the basics
of chess to play chess with it. This module does every task in python that is
possible in the real game.

4.2 LEGAL MOVES


Board.legal_moves
The board.legal_moves object is a generator, or more specifically
a LegalMoveGenerator. You can iterate over that object and it will yield something
with each iteration. You can convert it to a list with list(board.legal_moves) and
then index it as normal.
<LegalMoveGenerator at 0x3586100 (Nh3, Nf3, Nc3, Na3, h3, g3, f3, e3, d3, c3,
b3, a3, h4, g4, f4, e4, d4, c4, b4, a4)>

4.3 CHECKMATE
With the new rules from July 2014, a game ends as a draw (even without a claim)
once a fivefold repetition occurs or if there are 75 moves without a pawn push or
capture. Other ways of ending a game take precedence.
When a king is attacked, it is called check. A checkmate (also known as
"mate") occurs when a king is placed in check and has no legal moves to escape.
When a checkmate happens, the game ends immediately, and the player who
delivered the checkmate wins. Checkmating your opponent should be your top
priority since this will ensure your victory even if you have less material or if you

11
have had a worse position throughout the game. In the position below we can see
that White has less material but is able to deliver checkmate.

board.is_fivefold_repetition().

4.4 DRAW MATCH


Stalemate is a situation in the game of chess where the player whose turn it is to
move is not in check but has no legal move. The rules of chess provide that when
stalemate occurs, the game ends as a draw.
A draw occurs in chess when neither player wins nor loses—the game ends
in a tie. Either of the two players can ask for a draw, and after the game is tied, each
player wins half a point. Draws are more common among higher-rated players, but
even if you're still a beginner or intermediate player, you should know all the
drawing rules so no one catches you by surprise.

board.is_seventyfive_moves().

12
4.5 UML DIAGRAM

4.1 UML diagram.

13
CHAPTER 5
IMPLEMENTATION AND ANALYSIS

5.1 PYTHON LIBRARY


A Python library is a reusable chunk of code that you may want to
include in your programs/ projects. The Python Standard Library is a
collection of exact syntax, token, and semantics of Python. It comes bundled
with core Python distribution. We mentioned this when we began with an
introduction. For visualization of the dataset and prediction we use various
python
libraries.
Python libraries that are used in the project are:
 Pygame
 Sys
 Os

5.1.1 Pygame:
Python is the most popular programming language or nothing wrong to say that
it is the next-generation programming language. In every emerging field in
computer science, Python makes its presence actively. Python has vast libraries for
various fields such as Machine Learning (Numpy, Pandas, Matplotlib), Artificial
intelligence (Pytorch, TensorFlow), and Game development (Pygame,Pyglet).
 Pygame is a cross-platform set of Python modules which is used to create
video games.
 It consists of computer graphics and sound libraries designed to be used with
the Python programming language.
 Pygame was officially written by Pete Shinners to replace PySDL.

14
 Pygame is suitable to create client-side applications that can be potentially
wrapped in a standalone executable.

5.1.2 Sys:

The sys module in Python provides various functions and variables that are used
to manipulate different parts of the Python runtime environment. It allows
operating on the interpreter as it provides access to the variables and functions that
interact strongly with the interpreter. The sys modules provide variables for better
control over input or output. We can even redirect the input and output to other
devices. This can be done using three variables –

 stdin
 stdout
 stderr

5.1.3 Os:
The os module in Python is a library of functions for working with the operating
system. The methods it contains allow you to define the type of operating system,
access environment variables, and manage directories and files:
 check the existence of the object along the given path;

 determining the size in bytes;

 deletion;

 renaming, etc.

When calling os functions it is important to keep in mind that some of them may not
be supported by the current OS.

To use methods from os, you need to include a library. Python uses import os to do
this, which must be described in the file before calling the module for the first time.

15
5.2 DATA
The crucial element in python tasks for which a particular attention
should be clearly taken is the data. Indeed, the results will be highly
influenced by the data based on where did we find them, how are they
formatted, are they consistent, is there any outlier and so on. At this step,
many questions should be answered in order to guarantee that the learning
algorithm will be efficient and accurate. Many sub steps are taken to get,
clean and transform
the data.

5.3 FEASIBILITY STUDY


The object of the game of Chess is checkmate (See Table 1) and it can
happen in as few as four moves or less. Most checkmates, however, occur
within an average of 20-40 moves. In order to obtain a checkmate, a player
must recognize two fundamental principles:
1. One must take away all space from the opposing King.
2. Finally, one must attack the King.
The critical thinking/planning process to arrive at a successful conclusion
involves a few logical steps:
 How much space do I already control?
 What space do I need to control?
 What barriers inhibit my advance?
 How can they be removed in order to execute the process of
checkmate?
The correlate here, for example in business, is that bringing a product to
market requires the same methodology and skilled execution. Usually, a
company only gets one chance to bring a product to market correctly, and so
often in the game of Chess, a player may only get one chance to checkmate

16
the opponent.

17
5.3.1 ECONOMICAL FEASIBILITY
This study is carried out to check the economic impact that the system
will haveon the organization. Thus, the developed system requires an IDE and
person for data collection. The software is mostly open source and dataset can
be collected from the software.

5.3.2 TECHINICAL FEASIBILITY


This study is carried out to check the technical feasibility, that is the
technical requirements of the system. Any system developed must not have a
high demand on the available technical resources. This will lead to high
demands on the available technical resources. This will lead to high demands
being placedon the client. Thus, the developed system requires an IDE such
as Jupyter or
google colab to evaluate datasets and collection of dataset for different
environment conditions requires a person to follow the instructions.

5.3.3 SOCIAL FEASIBILITY

The aspect of study is to check the level of acceptance of the system by


the user. This includes the process of training the user to use the system
efficiently. The user must not feel threatened by the system, instead must
accept it as a necessity.

18
5.4 SOFTWARE DISCRIPTION
Python has huge set libraries which can be easily used for machine learning.
Python is one of the languages which can be used to write codes in the Map-
Reduce model while working in the Hadoop Ecosystem. Also, Spark, which is one
of the new technologies for scalable big-data analysis, has a machinelearning
library in python. So, simplicity and wider applicability goes hand-in- hand to
make it the so- called machine learning language. Python is an interpreter, high-
level, general- purpose programming language. Python has a design philosophy
that emphasizes code readability, notably using significant whitespace. It provides
constructs that enable clear programming on both small and large scales. Python
features a dynamic type system and automatic memory management. It supports
multiple programming paradigms, including object- oriented, imperative,
functional and procedural, it also has a comprehensivestandard library. Python
interpreters are available for many operating systems.

5.5 SAMPLE CODING (MAIN.py).


Sample code is an opportunity to directly influence how your users write
code. Therefore, sample code should set the best way to use your product. If
there is more than one way to code the task, code it in the manner that your team
has decided is best. If your team hasn't considered the pros and cons of each
approach, take time to do so.

The first and most basic example in a sample code set is usually termed a
Hello World program. After mastering the basics, engineers want more complex
programs. A good set of sample code provides a healthy range of simple, moderate,
and complex sample programs.

19
5.5.1 MAIN.PY
import pygame
import sys
from const import *
from game import Game
from square import Square
from move import Move
class Main:
def init (self):
pygame.init()
self.screen = pygame.display.set_mode( (WIDTH, HEIGHT) )
pygame.display.set_caption('Chess')
self.game = Game()
def mainloop(self):
screen = self.screen
game = self.game
board = self.game.board
dragger = self.game.dragger
while True:
# show methods
game.show_bg(screen)
game.show_last_move(screen)
game.show_moves(screen)
game.show_pieces(screen)
game.show_hover(screen)
if dragger.dragging:
dragger.update_blit(screen)
for event in pygame.event.get():
# click
if event.type == pygame.MOUSEBUTTONDOWN:
dragger.update_mouse(event.pos)
clicked_row = dragger.mouseY // SQSIZE
clicked_col = dragger.mouseX // SQSIZE

20
# if clicked square has a piece ?
if board.squares[clicked_row][clicked_col].has_piece():
piece = board.squares[clicked_row][clicked_col].piece
# valid piece (color) ?
if piece.color == game.next_player:
board.calc_moves(piece, clicked_row, clicked_col, bool=True)
dragger.save_initial(event.pos)
dragger.drag_piece(piece)
# show methods
game.show_bg(screen)
game.show_last_move(screen)
game.show_moves(screen)
game.show_pieces(screen)
# mouse motion
elif event.type == pygame.MOUSEMOTION:
motion_row = event.pos[1] // SQSIZE
motion_col = event.pos[0] // SQSIZE
game.set_hover(motion_row, motion_col)
if dragger.dragging:
dragger.update_mouse(event.pos)
# show methods
game.show_bg(screen)
game.show_last_move(screen)
game.show_moves(screen)
game.show_pieces(screen)
game.show_hover(screen)
dragger.update_blit(screen)
# click release
elif event.type == pygame.MOUSEBUTTONUP:
if dragger.dragging:
dragger.update_mouse(event.pos)
released_row = dragger.mouseY // SQSIZE
released_col = dragger.mouseX // SQSIZE
# create possible move

21
initial = Square(dragger.initial_row, dragger.initial_col)
final = Square(released_row, released_col)
move = Move(initial, final)
# valid move ?
if board.valid_move(dragger.piece, move):
# normal capture
captured = board.squares[released_row]
[released_col].has_piece()
board.move(dragger.piece, move)
board.set_true_en_passant(dragger.piece)
# sounds
game.play_sound(captured)
# show methods
game.show_bg(screen)
game.show_last_move(screen)
game.show_pieces(screen)
# next turn
game.next_turn()
dragger.undrag_piece()
# key press
elif event.type == pygame.KEYDOWN:
# changing themes
if event.key == pygame.K_t:
game.change_theme()
# changing themes
if event.key == pygame.K_r:
game.reset()
game = self.game
board = self.game.board
dragger = self.game.dragger
# quit application
elif event.type == pygame.QUIT:
pygame.quit()
sys.exit()

22
pygame.display.update()
main = Main()
main.mainloop()

5.5.2 GAME.PY
import pygame
from const import *
from board import Board
from dragger import Dragger
from config import Config
from square import Square
class Game:
def init (self):
self.next_player = 'white'
self.hovered_sqr = None
self.board = Board()
self.dragger = Dragger()
self.config = Config()
# blit methods
def show_bg(self, surface):
theme = self.config.theme
for row in range(ROWS):
for col in range(COLS):
# color
color = theme.bg.light if (row + col) % 2 == 0 else theme.bg.dark
# rect
rect = (col * SQSIZE, row * SQSIZE, SQSIZE, SQSIZE)
# blit
pygame.draw.rect(surface, color, rect)
# row coordinates
if col == 0:
# color
color = theme.bg.dark if row % 2 == 0 else theme.bg.light
# label

23
lbl = self.config.font.render(str(ROWS-row), 1, color)
lbl_pos = (5, 5 + row * SQSIZE)
# blit
surface.blit(lbl, lbl_pos)
# col coordinates
if row == 7:
# color
color = theme.bg.dark if (row + col) % 2 == 0 else theme.bg.light
# label
lbl = self.config.font.render(Square.get_alphacol(col), 1, color)
lbl_pos = (col * SQSIZE + SQSIZE - 20, HEIGHT - 20)
# blit
surface.blit(lbl, lbl_pos)
def show_pieces(self, surface):
for row in range(ROWS):
for col in range(COLS):
# piece ?
if self.board.squares[row][col].has_piece():
piece = self.board.squares[row][col].piece

# all pieces except dragger piece


if piece is not self.dragger.piece:
piece.set_texture(size=80)
img = pygame.image.load(piece.texture)
img_center = col * SQSIZE + SQSIZE // 2, row * SQSIZE +
SQSIZE // 2
piece.texture_rect = img.get_rect(center=img_center)
surface.blit(img, piece.texture_rect)
def show_moves(self, surface):
theme = self.config.theme
if self.dragger.dragging:
piece = self.dragger.piece
# loop all valid moves
for move in piece.moves:

24
# color
color = theme.moves.light if (move.final.row + move.final.col) % 2 == 0
else theme.moves.dark
# rect
rect = (move.final.col * SQSIZE, move.final.row * SQSIZE, SQSIZE,
SQSIZE)
# blit
pygame.draw.rect(surface, color, rect)
def show_last_move(self, surface):
theme = self.config.theme
if self.board.last_move:
initial = self.board.last_move.initial
final = self.board.last_move.final
for pos in [initial, final]:
# color
color = theme.trace.light if (pos.row + pos.col) % 2 == 0 else
theme.trace.dark
# rect
rect = (pos.col * SQSIZE, pos.row * SQSIZE, SQSIZE, SQSIZE)
# blit
pygame.draw.rect(surface, color, rect)
def show_hover(self, surface):
if self.hovered_sqr:
# color
color = (180, 180, 180)
# rect
rect = (self.hovered_sqr.col * SQSIZE, self.hovered_sqr.row * SQSIZE,
SQSIZE, SQSIZE)
# blit
pygame.draw.rect(surface, color, rect, width=3)
# other methods
def next_turn(self):
self.next_player = 'white' if self.next_player == 'black' else 'black'

25
def set_hover(self, row, col):
self.hovered_sqr = self.board.squares[row][col]
def change_theme(self):
self.config.change_theme()
def play_sound(self, captured=False):
if captured:
self.config.capture_sound.play()
else:
self.config.move_sound.play()
def reset(self):
self. init ()

5.7 SAMPLE OUTPUT

5.1 Basic design of chess board

26
5.2 When a piece is selected

5.3 When a piece is moved

27
5.4 When there is a check.

5.5 When there are multiple queens replaced by pawns and a checkmate

28
CHAPTER 6
CONCLUSION

The potential applicability of learning Chess as a tool, especially at an early


age, to increase skills essential to more successful leadership. The chess game can
be very interesting and it helps us to develop our IQ. There are three recognized
phases in a chess game: the opening, where piece development and control of the
centre predominate; the middlegame, where maneuvering in defense and attack
against the opponent’s king or weaknesses occurs; and the endgame, where,
generally after several piece exchanges, pawn promotion becomes the dominant
theme. From these findings we can conclude the Game of Kings - Chess is a ield of
development of the most critical and necessary skills required by leaders across
every endeavor. It appears to be the missing element in education practice that goes
beyond lecture and assessment, rote memorization of facts, and into pure mental
and psychological development that American school systems are currently
struggling to provide students.

29
REFERENCES

1. [Burg and Just, 1987] Daniel B Burg and Tim Just.IUS Chess Fed-eration
Official Rules of Chess. McKay, New York, 1987

2. Philidor, F. D. (1777).Analysis of the game of chess.London: P. Elmsley

3. Shane, S., & Venkataraman, S. (2000). The promise of entrepreneurship as a


field of research.

4. Kahneman, D., & Klein, G. (2009). Conditions for intuitive expertise.

5. https://python.plainenglish.io/getting-and-analysing-chess-game-data-with-
python-71c97494a5f4

6. Campitelli, G., & Gobet, F. (2008). The role of practice in chess: A


longitudinal study.

7. Carland, J. W., & Carland, J. C. (2003). Pawn takes Queen: The strategic
gameboard in entrepreneurial irms. Academy of Strategic Management,
2, 97-109.

8. Thompson, H. (2007). A summary analysis of IQ and EQ by leader level.


High Performing Systems, Inc., Technical Report 15-10.

9. Giang, V. (2012, July 16). Exclusive: Entrepreneur challenges Peter Thiel to


million dollar chess game. Business Insider. Retrieved from:
http://www.businessinsider.com/steigman-challenges-thiel-to-million-dollar-
chess-game-2012-7.

10.Hoffjan, A. (2003). Go and Chess as prognosis instruments for


understanding competitive positions. Strategic Change, 12, 435-442.
Doi:10.1002/jsc.647. Kazemi, F., Yektayar, M., & Abad, A. M. B.
(2012).

30

You might also like