Uploaded by LiveLeakVeteran

chess WRITEUP

advertisement
OCR GCE A
COMPUTER SCIENCE
PROJECT
H446-03
Name :
Hassan Khawaja Ahmed Roohi
Candidate Number:
0591
Institution Name:
Salford City College Pendleton Centre
Centre Number:
33349
Title of Project:
King’s Survival
Page 1 of 145
H446-03 – PROJECT CONTENTS
TABLE OF CONTENTS
Table of Contents ..........................................................................................................................................................2
Analysis ..........................................................................................................................................................................5
PROBLEM DESCRIPTION ............................................................................................................................................5
STAKEHOLDERS .........................................................................................................................................................5
JUSTIFICATION ...........................................................................................................................................................6
RESEARCH ..................................................................................................................................................................7
EVALUATION OF RESEARCH ......................................................................................................................................9
INTERVIEW ..............................................................................................................................................................10
FEATURES ................................................................................................................................................................12
Essential features: ...............................................................................................................................................12
Desirable features & Limitations: ............................................................................................................................13
Limitations: ..............................................................................................................................................................14
Limitations: ..............................................................................................................................................................14
HARDWARE AND SOFTWARE REQUIRMENTS .........................................................................................................15
SUCCESS CRITERIA ...................................................................................................................................................16
DESIGN .........................................................................................................................................................................18
SYSTEM DIAGRAM ...................................................................................................................................................18
SUMMARY OF PROCESS ..........................................................................................................................................19
DESIGN OF USER INTERFACE ...................................................................................................................................21
DESIGN OF GAME SCREEN ......................................................................................................................................22
TEST DATA ...............................................................................................................................................................24
CLASS DIAGRAM ......................................................................................................................................................26
ALGORITHMS ...........................................................................................................................................................28
GAME MODE SELECTION .....................................................................................................................................28
MOVING A PIECE..................................................................................................................................................29
PROMOTION ........................................................................................................................................................30
CHECKMATE .........................................................................................................................................................31
FIFTY MOVE RULE ................................................................................................................................................32
GUIDING POINTER ...............................................................................................................................................33
Linking the Algorithms .........................................................................................................................................34
TEST DATA FOR APLHA TESTING .............................................................................................................................35
Page 2 of 145
POST DEVELOPMENT TEST PLAN ............................................................................................................................37
Main Menu ..........................................................................................................................................................37
Board SetUp .........................................................................................................................................................38
Pawn Movements ................................................................................................................................................38
Rook Movements .................................................................................................................................................39
Bishop Movements ..............................................................................................................................................40
Knight Movements ..............................................................................................................................................40
Queen Movements ..............................................................................................................................................41
King Movements ..................................................................................................................................................42
Guiding Pointer ....................................................................................................................................................42
Game Over ...........................................................................................................................................................43
Pawn Promotion ..................................................................................................................................................44
Sound Features ....................................................................................................................................................45
SIGN OFF PROPOSAL ...............................................................................................................................................45
DEVELOPING THE CODED SOLUTION (“THE DEVELOPMENT STORY”) .........................................................................46
Creating the Main Menu-13/10/2021 .....................................................................................................................46
Main Menu Screen- ProtoType 1 .........................................................................................................................49
Main Menu Screen- ProtoType 2 .........................................................................................................................50
Main Menu Screen- ProtoType 3 .........................................................................................................................51
Creating the Chess Board-27/10/2021 ....................................................................................................................52
Creating the pieces-3/10/2021 ...............................................................................................................................55
Moving the pieces-10/11/2021 ...............................................................................................................................58
Eliminating Pieces-17/11/2021 ...............................................................................................................................61
Moving and Elimination Testing ..........................................................................................................................62
Undo Moves-25/11/2021 ........................................................................................................................................63
Stakeholders Feedback ...........................................................................................................................................65
Generating Valid moves-02/12/2021 ......................................................................................................................66
Validating Pawn moves ........................................................................................................................................67
Validating Rook moves ........................................................................................................................................72
Validating Bishop moves......................................................................................................................................77
Validating Queen moves ......................................................................................................................................82
Validating Knight moves ......................................................................................................................................86
Validating King moves..........................................................................................................................................89
Valid Move generation Testing ............................................................................................................................93
Checkmate and Stalemate-17/12/2021 ..................................................................................................................93
Page 3 of 145
Promotion-03/01/2022 ...........................................................................................................................................99
Stakeholders Feedback .........................................................................................................................................105
Guiding Pointer- 02/02/2022 ................................................................................................................................105
Sound Effects & MuSic- 10/02/2022 .....................................................................................................................109
Testing Videos ....................................................................................................................................................110
Stakeholders Feedback .........................................................................................................................................111
EVALUATION ..............................................................................................................................................................112
POST DEVELOPMENT TESTING ..............................................................................................................................112
Main Menu ........................................................................................................................................................112
Board SetUp .......................................................................................................................................................113
Pawn Movements ..............................................................................................................................................114
Rook Movements ...............................................................................................................................................114
Bishop Movements ............................................................................................................................................115
Knight Movements ............................................................................................................................................116
Queen Movements ............................................................................................................................................117
King Movements ................................................................................................................................................118
Guiding Pointer ..................................................................................................................................................119
Game Over .........................................................................................................................................................120
Pawn Promotion ................................................................................................................................................121
Sound Features ..................................................................................................................................................122
Solutions’ Comparison to Success Criteria ............................................................................................................123
Limitations of Solution .......................................................................................................................................127
Changes During Development ...............................................................................................................................127
Usability Features ..................................................................................................................................................127
Unmet Usability Features ..................................................................................................................................129
Future Maintenance ..............................................................................................................................................129
Maintaing the System (Perfective and Adaptive) ..............................................................................................129
Possible Future Features ...................................................................................................................................130
Limitations of possible Future features ............................................................................................................131
Summary ............................................................................................................................................................131
Project Appendixes ....................................................................................................................................................132
Game Engine ......................................................................................................................................................132
Main file .............................................................................................................................................................139
Page 4 of 145
ANALYSIS
PROBLEM DESCRIPTION
My project is a 2-dimensional chess game. The reason behind choosing this as my project is that it’s my
favorite pass time. I lost a few pieces of my chess game and in these unprecedented times and I was
unable to buy a new one, So I decided to build a game of my own so next time I don’t have to worry
about losing chess pieces again.
The game’s format would be 1v1 and it will allow the users to perform basic chess moves on the pieces
all based on the objective of capturing the enemy’s king piece Chess is played on a square board divided
into eight rows of squares called ranks and eight columns called files, with a dark square in each player's
lower left corner. This is altogether 64 squares. The colors of the squares are laid out in a checker
pattern in light and dark squares. To make speaking and writing about chess easy, each square has a
name. Each rank has a number from 1 to 8, and each file a letter from a to h. This means that every
square on the board has its own label, such as g1 or f5. The pieces are in White and Black sets. The
players are called White and Black, and at the start of a game each player has 16 pieces. The 16 pieces
are one king, one queen, two rooks, two bishops, two knights and eight pawns.
As both players would be trying to save their king pieces, so I have named the game “King’s survival”. As
chess is all about making right moves at the right time at the right time the game to encourage
beginners to improve their skills I have decided to introduce a guiding pointer which will show the
possible moves that can be carried on a piece when selected. Keeping in mind that time is also an
important aspect of the game I have decided to introduce 3 different times to add to the competitive
nature of the game.
STAKEHOLDERS
For keeping the game fair for both professional and beginner players I have chosen one stakeholder
from each category.
STAKEHOLDER 1: SAYEM
My first stakeholder is my friend named Sayem. Sayem is a college student and have competed in
national level chess competitions. He has been playing chess for more than a few years and has already
mastered lot of tricks. He also has the eager to learn about the process of game development and is
looking forward to giving his useful input to this project. His feedback on game would be extremely
useful as he is preparing himself for an online chess competition, so his experience of playing it on
computer can help me know if it would attract professional players.
STAKEHOLDER 2: ALI
My second stakeholder is my other friend Ali. He is also a college student but unlike Sayem he has just
started to learn the game of chess. Ali is a video game enthusiast, and he actively takes part in online
gaming competitions. Ali wants to learn the fundamentals of the chess game and wants to add it to his
computer games armoury. His perspective of the game would be extremely useful as he has loads of
Page 5 of 145
experience in online gaming and him playing as a new player would give me idea how the beginner
players would perceive the game.
Overall, these two stakeholders will be very useful in the process due to the contrasting viewpoints,
from a new player to professional one, their outlook on computer gaming and their interest in the chess.
JUSTIFICATION
Justifying why this problem should be solved by
Computational Methods
With the growing need of technology, it is necessary to keep up these games with the advancements in
technology. As nowadays people like the competitive nature of the game and they also enjoy the
opportunity to engage people from distant places. With physical setups it is hard to achieve this but with
computational methods we can overcome this problem. As someone who was eager to learn the game
myself it was hard to keep up to all the possible moves that can be made and what they would result in,
for example if someone is trying to make themselves familiar with the movements of different pieces it
could be hard to remember and even more annoying if you are trying to make moves that are not even
valid. We can keep track of all possible moves just on one simple click of the mouse so proving that my
method of solving the computationally would be effective.
ABSTRACTION
During the development of this program many aspects can be abstracted out due to there not being a
need for them or just not fitting the description of the project. For example, a piece can be shifted onto
the desired position on the board by just appearing on that position instead of graphically showing how
the piece would move from one position to another. This will take much less processing and we would
be able to focus on our main goal of just moving piece but not how it would be moved. Also, in time
modes the clock will stop as soon as player has made his move unlike the actual game where they must
press the clock timers by themselves every time, they complete a move. This is abstracted so the player
does not have to worry about pressing a button on screen every time they make a move, it would also
support by saving some valuable development time.
DECOMPOSING MY PROBLEM
While developing my website I will have to break down the problem into many little parts, this is to increase
efficiency of the code and make the program easily understandable for later updates. As well as this it will be much
easier to develop.
A rough overview of the decomposed steps:
• Main menu screen
o Gameplay
o
-Creating a board
-Creating the pieces
-Movements of the pieces
-Eliminating the pieces
-Termination of game
Information
-Setup of the game
-How pieces could be moved
-How can you win a game
Page 6 of 145
o
Quit
-Terminating the game
THINKING PROCEDURALLY
While playing the game the user would be able to interact with the game using mouse. This is for
selecting and moving pieces and selecting different modes by just clicking on the screen. So, the user
can play the game which in necessary for the project to work.
From this the user will receive visual output such as the selected piece moving on the screen or certain
positions on the board being highlighted when a piece is selected guiding the user what they can do
next. Doing this will help me accomplish what the actual program is attended to do.
RESEARCH
Similar Games
To knowing how other similar games work I went on to play those games and take note of the features
they are offering and how it is enhancing the players experience.
The first game I came across was Chess.com which is a
two-dimensional chess game. The game comes with loads
of exciting features. The user has the option to choose to
play with either a computer bot or any other player. It also
offers levels of computer bots from beginner to master
which is very fascinating.
The game also has different time modes which are
competitive. It also comes with a guiding pointer in few
modes which is one of the desirable features of my project
as well. In terms of gameplay, it is smooth and quite easy
to play. One of its most unique features is the moves
board. In this section it keeps a record of all the moves made and comments whether the move was
excellent move, good move, bad move, or a blunder. It also displays the count of blunders and missed
win at the end of every game. Overall, the game provides an excellent gaming experience.
The second game I came across was mathsisfun.com. This
game is also a two-dimensional game. At the very beginning
of game, it comes with a manual of how you can play the
game. It can be played against a computer or a friend on the
same computer. It offers the user to pick colour of pieces,
style of pieces and the length of the game. Like chess.com
it also produces different level of computer programmed
bots. Unlike chess.com you cannot play online with other
players or compete in any tournament.
The gameplay is much like most of the games available out
there and is quite easy to play. It also offers a guiding
Page 7 of 145
pointer which is a beneficial tool for beginner players. The colour choosing option is extremely useful for
people who are colour blind so they can enjoy the game as well.
The third game I came across was Chess24.com which also a two-dimensional chess game as the other
two games discussed above. It is also remarkably similar
to the other games in terms of features it offers to the
user like the option to play against a computer bot or any
other online player. Different time modes are also
available. In addition to this it also has a leader board
where it ranks all the players who played in last 24 hours
according to their number of wins. It also tells the
number of users which are online right now.
The most unique feature of this game is the move marker
where it highlights the last move of the user so they can
know what move they or their opponent made
previously. In terms of gameplay the game is
exceptionally smooth and equally interesting for both
professional players who are looking for some
competition or to beginners who are still learning the game.
The fourth and the last game I came across was SparkChess.com this game is three-dimensional chess
game. The game starts with providing the user three options to choose from which are named learn,
practice and challenge.
Learning mode is for teaching
beginner player basic moves
while in practice mode you can
compete against a computer
bot of level of your choice. In
challenge mode the user can
compete against a friend or
any other online player.
Like all the games discussed
before this game also offers a guiding pointer and move log. The most unique feature of this game is
the option to undo a move in practice or learn mode which other games does not offer. It also displays a
clock on the top so user could be aware of the time they took making a move. It also offers the user to
compete in game restricted to time and have various time modes. The gameplay is designed in such way
that it is not too difficult to play. The board is made with high contrast colors with a black background
which makes the game look good.
Page 8 of 145
EVALUATION OF RESEARCH
Here is an evaluation of research to discuss the features that can be included to my game to enhance
the user experience.
Feature
Description
Conclusion
Time-modes
The user is required to complete the
game in certain time limit. A clock
counts down the remaining time for
a user, and they must complete the
game before they run out of that
time else it would result in them
losing the game.
This would require quick responses and
high concentration so adding to intensity of
the game. Making the game competitive
and appealing to professional players. So, I
have decided to introduce this feature in
my game as well.
Guiding pointer
This displays the position on the
board a piece could be moved to
when you click on a piece after
selecting it. It is done by either
highlighting that square or some
other sort of marking.
This feature is extremely useful for players
who are learning to play the game as if
they are unsure how a certain piece could
be moved, they could know by just clicking
on it. This would encourage beginners so
this feature would be included in my game.
Computer bots
A computer bot in terms of this
game would be computer-controlled
player programmed to make chess
moves just like a human but much
faster. They can come in different
levels.
Although this feature is very fascinating but
requires a high level of programming and a
lot of knowledge about chess as well.
Programming different level of bots could
be exceedingly difficult and time
consuming so for this computer bots would
not be a part of my game.
Move log
A move log just keeps a track of all
the moves made by both players and
represents them in a certain
notation.
This feature could be good for analysing
the game. The inclusion of this feature
would be decided after discussing with
stakeholders.
Board colour picker
This will simply allow the user to pick
two colours which the board will
display in terms of alternating
squares.
Although this feature may look very
appealing and is very achievable, but I have
decided to not include this feature for now
so can focus on other essential features.
Evaluation of moves
This analysis the current move made
by the user and gives a comment
such as: blunder, bad, good, and
excellent. This comment is then
displayed on the side of the screen.
This would require the evaluator to be
aware of all the different moves and their
effects. This would be a bit complex to
achieve and would slow down the
gameplay.
Previous move
highlighting
This will indicate the previous move
made by a user by highlighting its
path.
This feature can be extremely useful for a
player to predict what another player’s
next move could be but may result in
gameplay to not run as smoothly as it is
supposed to.
Page 9 of 145
INTERVIEW
Questions:
Sayem
Ali
Conclusion:
How should the
pieces move
around the
screen?
I think the for the
movement of pieces
mouse would be a better
option as compared to
keyboard as it would be
much faster to select and
drop pieces by clicking.
The chess pieces would be
moved around by first
selecting a piece and then
clicking on the position
where we want to move the
piece.
Should we
display the
eliminated pieces
on the side of the
board or not?
How many time
modes there
should be?
I think it is not necessary
to display the eliminated
but there is no harm in
doing such.
As someone who has
plays platform games
more regularly, I have
noticed that most of the
games are played with
keyboards but at this
instance I agree with
Sayem.
I think we should display
the eliminated pieces on
side as it would seem
more realistic.
More time modes may
cause in new players to
struggle more so I think
there should be only 2time modes so both new
and old players can
enjoy the game.
2 minutes would be to
less for a game we
should have at least 5
minutes for the shortest
mode while the longest
mode can go up to 20
minutes.10 minutes
would be enough for the
medium difficulty one.
I think the guiding
pointer is an extremely
helpful feature as it will
allow beginners to learn
the game faster.
The game should end as
a draw or we should ask
both users to add more
time?
As time modes are optional
for the players so there will
not be a lot of problem if we
have at least 3-time modes.
I think music or sounds
will increase the
intensity and enhance
the overall game
experience.
Sounds/ music would be
played once the game ends,
or a player gets eliminated.
For me competitive
nature of the games
excites me the most so I
think there should be at
least 3-time modes to
make the game more
exciting.
What timeframe For the longest time
we should
mode, we should allocate
allocate for each 10 minutes while the
mode?
shortest time mode
should consist of 2
minutes and for the third
one, we can allocate
anything between 10 and
2 minutes.
Should we have
Guiding pointer may be
guiding pointer?
unfair as it may as if you
do not know what to do
next you may better
withdraw the game.
What will happen If one of the players runs
if none of the
out of time the other
players are able
player should be
to win within the automatically awarded a
given period?
win
Should we have
I think it is unnecessary
any sounds or
and it may cause the
music when a
players a bit of
piece gets
distraction.
eliminated or the
game ends?
Eliminated pieces would be
displayed on the side of the
board.
The shortest time mode will
be 5 minutes long, the
medium time mode would
be 10 minutes long. And
finally, the longest time
mode would be no longer
than 15 minutes.
There would be a guiding
pointer which will indicate
the possible moves when a
piece is selected.
The game would be awarded
to the opposition player if
one runs out of time.
Page 10 of 145
After the game
ends do you
want the have
the option to ask
the user to start
a new game from
there?
While playing a
game what is the
thing which
stands out to you
the most?
Should the player
have to option to
undo a move?
Yeah sure, I think that
would be helpful.
Yeah of course we
should have this feature
as it would be much
slower to go back to
menu and start a new
game.
Players would have an
option to start new game
once a game has ended.
For me easy controls and
competitive modes are
everything.
The graphics of the
game appeal me the
most.
The graphics and the
controls are important if
want to appeal more users.
Yes, I believe this option
should be available to the
player.
Should we have a
button which
allows a player to
resign?
Yeah sure, having a
button for resigning next
to each player icon would
make resigning easier.
The player would have an
option to undo a move by
mutual agreement with the
opposite player.
A resign button will be
added next to each player
icon.
Do you want the
player names to
be displayed next
to the player
icon?
Yeah definitely, I think
this would be helpful
when distinguishing
which player has been
allocated which piece
colour.
I am unsure about this
because it may result in
player losing focus as
now, they are
concentrating on just
time instead of the actual
game.
I think there should be a
button next to each
player icon. This button
should highlight
whenever a draw by fiftymove rule is applicable.
The player would be able
to claim the draw by
pressing it.
Yes, as accidentally
making a move is
possible so this option
would help tackle it.
Yes, this should be
added as the player
must have some way to
resign if they do not
wish to continue the
game.
I think this would make
the game more
appealing if the player
can see their names in a
cool text style next to
their icon.
Yeah definitely, as this
would add to the
element of intensity and
improve the gaming
experience.
I agree with the idea
presented by Sayem,
and I believe it is the
best way to implement
this feature. In addition,
a pop message on the
side stating that this rule
is applicable now would
also be great.
A button for claiming draw
by fifty-move rule would be
added next to each player
icon. It would highlight when
the fifty-move rule is true
indicating that either player
can now claim a draw under
this rule.
Should we have a
sound to indicate
that the player
has then thirty
seconds left on
the timer?
How would you
like the player to
claim draw by
fifty-move rule?
The players name would be
displayed next to their
respective icons.
A sound effect would be
added to notify the player
that they have less than
thirty seconds left in the
time mode.
Page 11 of 145
FEATURES
ESSENTIAL FEATURES:
-Setup and Board:
Chess is played on a square board divided into eight rows of squares called ranks and eight columns
called files, with a dark square in each player's lower left corner. This is altogether 64 squares. The
colors of the squares are laid out in a checker pattern in light and dark squares. To make speaking and
writing about chess easy, each square has a name. Each rank has a number from 1 to 8, and each file a
letter from a to h. This means that every square on the board has its own label, such as g1 or f5. The
pieces are in White and Black sets. The players are called White and Black, and at the start of a game
each player has 16 pieces. The 16 pieces are one king, one queen, two rooks, two bishops, two knights
and eight pawns.
- Pieces and Movements:
Following is a brief description of the pieces and their respective movements:
•
•
•
•
•
•
•
The King moves one square in any direction. The king is the most valuable piece — attacks on the
king must be immediately countered, and if this is impossible, immediate loss of the game ensues.
A Rook can move any number of squares along a rank or file but cannot leap over other pieces.
A Bishop can move any number of squares diagonally but cannot leap over other pieces.
A Queen combines the power of a rook and bishop and can move any number of squares along a
rank, file, or diagonal, but cannot leap over other pieces.
A Knight moves to any of the closest squares that are not on the same rank, file, or diagonal. (Thus,
the move forms an "L"-shape: two squares vertically and one square horizontally, or two squares
horizontally and one square vertically.) The knight is the only piece that can leap over other pieces.
A Pawn can move forward to the unoccupied square immediately in front of it on the same file, or
on its first move it can advance two squares along the same file, provided both squares are
unoccupied (black dots in the diagram). A pawn can capture an opponent's piece on a square
diagonally in front of it by moving to that square (black crosses).
No piece may move to a square occupied by a piece of the same color.
-Capture:
Most pieces capture as they move. If a piece lands on an opponent's piece, the opposing piece is taken
off the board. There are three special cases:
• The king cannot be taken.
• No piece can be taken while castling.
• Pawns take one square diagonally.
Page 12 of 145
-Promotion:
Promotion in chess is a rule that requires a pawn that reaches the eighth rank to be replaced by the
player's choice of a bishop, knight, rook, or queen of the same color. The piece chosen cannot be
another king nor another pawn. The new piece replaces the pawn on its square on the same move. The
choice of the new piece is not limited to pieces previously captured, thus promotion can result in a
player owning, for example, two or more queens despite starting the game with one.
-Checkmate:
When a king is under immediate attack, it is said to be in check. A move in response to a check is legal
only if it results in a position where the king is no longer in check. This can involve capturing the
checking piece; interposing a piece between the checking piece and the king (which is possible only if
the attacking piece is a queen, rook, or bishop and there is a square between it and the king); or moving
the king to a square where it is not under attack.
The object of the game is to checkmate the opponent; this occurs when the opponent's king is in check,
and there is no legal way to get it out of check.
-Forms of termination:
A game can be won in the following ways:
•
•
•
Checkmate: The king is in check and the player has no legal move.
Resignation: A player may resign, conceding the game to the opponent.
Win on time: In games with a time control, a player wins if the opponent runs out of time, even if
the opponent has a superior position, if the player has a theoretical possibility to checkmate the
opponent were the game to continue.
-Draw:
There are several ways a game can end in a draw:
•
•
•
Stalemate: If the player to move has no legal move, but is not in check, the position is a stalemate,
and the game is drawn.
Dead position: If neither player can checkmate the other by any legal sequence of moves, the game
is drawn.
Fifty-move rule: If during the previous 50 moves no pawn has been moved and no capture has been
made, either player can claim a draw.
DESIRABLE FEATURES & LIMITATIONS:
-3 Times modes:
We have decided to introduce 3 times modes in the game to make it more competitive. Both players are
given the same time slot at the start of the game. The time goes down as soon as opponent makes a
move, and the clock goes on until a move is made. A player can win the game by checkmate or other
player resigning within the given time slots. If neither of this happens a player wins if the opponent runs
out of time, even if the opponent has a superior position. Following are the 3 times modes:
Page 13 of 145
-Rapid fire: This mode gives each player 5 minutes throughout the game to make their moves with the
ultimate goal of checkmating the other player within the available time.
-Quick breeze: This mode compromises of each player getting 10 minutes in which both players aiming
to checkmate other player within the given time limit.
-Relaxed water: This mode is much closer to a casual game of chess. Each player gets 15 minutes so
there is not much risk of losing by time as compared to other time modes. All forms of termination in a
time modes which are described above are applicable.
LIMITATIONS :
Although this feature is very appealing as it adds to the intensity of the game and makes it much more
competitive but implementing it efficiently could be a bit difficult. This would require separate clocks for
both players, at start when one player is required to make the move the clock will countdown from the
time the player was granted. The clock will keep counting down until a move is made and would record
the time the move is made and now the clock of first player is stopped and now the second player’s
clock would be activated. When the first player gets a turn again, they would start from the time they
last left, and the game will keep going on until a player wins the game or one of the players runs out of
time. In case a player runs out of time the other player would be automatically declared winner. The
process of clocks starting and stopping and at same time keeping an eye for a checkmate is a bit
complex to implement.
-Rules and Info:
We have also decided to list all the rules of the gameplay so beginner players can benefit from as it
would be good learning tool. This will include the legal moves for all the pieces and how they can
capture opponent’s piece, etc. Along the rules I will also state the necessary information a player would
require playing the game. This would include how a player can (select a piece, move a piece, capture a
piece, choose a piece for promotion, etc.) on the screen.
-Guiding pointer:
To further enhance the experience of the players we have decided to introduce a guiding pointer to the
game. The purpose of the pointer is to show all the possible moves that could be made with a certain
piece once a piece has been selected by the player.
LIMITATIONS:
This feature could be a bit difficult to implement. This feature is dependent upon the pieces and
movement feature as for indicating where a piece could be moved to it should know all the moves
which are valid for a certain piece. But it also must take some other factors in account like the current
game state. For instance, a move maybe valid but if another piece of the same team is already
occupying that position or that position lies in the path of possible moves the process of deciding
whether the guiding pointer should indicate the positions beyond those pieces is hard to implement.
Page 14 of 145
-Sound effects:
Emphasizing more on the user’s experience we also look forward to introduce sound effects to the
game. These sound effects would be initiated once a piece is moved, a piece is captured, the king is in
check and once a game has been won.
HARDWARE AND SOFTWARE REQUIRMENTS
Requirements
Justification
Computer
To get on the game.
Mouse
To click on pieces and moving them along the screen. Selecting a menu
button so mouse is essential for overall interacting with the game.
Monitor
So, they can see the user interface (menu screens, the board, the pieces).
Intel Pentium 4 or later
To have a reasonably modern CPU architecture that supports python
programs to run.
25 Gb or more of diskspace
This is to have, and OS installed and be able to install the game.
Over 4Gb of RAM
So, the game can load everything on the screen at a reasonable speed.
Windows 7 or above
Needed to use the game. Anything below that may not be capable of
displaying the graphics or may not be compatible with the game.
Python interpreter
As the code is written in python a python interpreter would be most
compatible option as a compiler may slow down the execution.
Speakers
As sound effects would be a part of the game so speakers would be
required to output audio.
Pygame Library
The pygame library has many prewritten and pretested program
components which would be useful in developing this game. These
resources can be used multiple times during the game so would reduce
coding and need for testing.
Page 15 of 145
SUCCESS CRITERIA
Specified Requirements
Justification
Testing
The chess pieces can move on
the board.
The player must be able to move
the pieces across the board to play
the game.
Selecting the piece by
clicking on it and then
clicking on the desired
position on the board.
The board is setup like real
chess board.
The board setup is necessary as
otherwise problems will arise with
moving pieces which will affect the
gameplay.
After the board has been
developed recheck it with
the proportions of a real
board.
A piece can eliminate another
piece.
In order the game to work like an
actual chess game player must be
able to eliminate other player’s
pieces.
Select own piece and then
select o the position which is
already occupied by one od
opponents’ pieces.
The pieces stay within the
bounds of the board.
If the piece would leave the board
while making a move it would not
be realistic as a piece cannot make
a move on position which is not on
the board.
Randomly click anywhere
outside the board so by
doing no move should be
made.
The player can see possible
moves they can make when
they select a particular piece.
This is more of a desirable feature
but is useful as it will allow the user
to know what possible moves can
be made if they are unsure.
Select a piece by clicking on it
all the possible positions it
can move to should be
highlighted.
In time modes it displays the
remaining time.
If the timer is not available in the
time mode than the player will not
be able to keep track of remaining
time.
Start a game in time mode
and check the timer after the
end of every move.
The game ends when the king
cannot escape (Checkmate).
This is one of the main objectives of
the game as a win cannot be
attained without capturing another
player’s king.
Play a game in which one
player can capture other’s
king so winner should be
displayed, and game must be
terminated.
Page 16 of 145
The game ends when there are
no valid moves to be made
(Stalemate).
If no legal moves can be made to
checkmate the king, the game
should end as that is what would
happen in a real game of chess.
Play the game and get it to
such position where game
cannot be won by checkmate
so game should terminate
without any winner.
If a pawn reaches the farthest
position on the board, it can be
promoted to a higher rank
piece.
In case a pawn reaches the other
end of the board it should be
promoted to a higher rank piece
such as a queen. This is because
that is what would happen in a real
game of chess.
Take a pawn to its farthest
position and see if promotion
is allowed or not.
The player gets the option to
choose the type of piece they
want their pawn to be
promoted to.
To promote the pawn, the player
must choose what type of piece
they want it to be promoted to so
some form of choice input system
would be required.
Take a pawn to its farthest
position and see if the player
is asked for some sort of
input for promotion choice.
The player can resign the game
using a resign button and win
should be awarded to the other
player.
If at any point a player wishes to
resign, they should have the option
to do so, and win should be
awarded to other player. As this is
what would happen in a real game.
Click on the resign button
and see if the game over
screen loads and win is
awarded to the other player.
The player can perform castling
if it is a valid move.
Castling is one of the legal moves in
chess where a king can crossover a
rook in a certain way. It is valid
move and player should be able to
perform it in the game.
Move the king two squares
toward a rook on the same
rank and moves the rook to
the square that king has
crossed.
The player can perform an en
passant using a pawn piece.
En passant is type of capture move
in chess which involves pawns only.
It is allowed in a real game so the
player should be able to perform it
here as well.
Move a pawn horizontally
adjacent to an enemy pawn
and see if it is eliminated or
not.
The game should end as a draw
if no elimination has been
made or no pawn has been
moved in the last fifty moves.
Fifty-move-rule is a rule in chess.
This allows either player to claim a
draw under certain circumstances.
So, this form of termination should
be allowed.
Move no pawns and
eliminate no pieces for fifty
moves to see if game over
screen loads and a draw is
announced.
The player is only allowed to
make valid moves and invalid
moves are not executed.
For a fair and fully functioning
game to take place it is necessary
that only valid moves allowed while
invalid are discarded.
Try invalid moves these
should not be executed then
try all valid move if all
allowed then functioning
properly.
Page 17 of 145
DESIGN
SYSTEM DIAGRAM
Page 18 of 145
SUMMARY OF PROCESS
Main Menu:
The main menu consists of three option which are Play, Info, and Quit. The user would be able to
navigate through the game using these.
Play:
The Play option is responsible for organizing a one versus one game of chess game for the user. It
consists of different gaming modes and the all the gameplay.
•
Game loop: The game loop contains all the logic behind the gameplay from displaying the chess
board to eliminating pieces and terminating the game by different methods all are contained in
the game loop.
• Normal: This is one of the game play modes. In this mode a chess game would be carried out
without any time restriction so the game would only be won by either one player checkmating
the other player or one of the players resigning the game.
• Time-mode: This is the other game play mode. In this mode the players are bound to complete
the game within a limited time restriction else if one runs out of time other is granted a win.
o Time-mode selection: This allows the user to choose any of the three time-modes
available.
o Clock: The clock indicates how much time each player must make moves.
• Board: This contains the logic behind creating and graphically representing the board.
o Game condition: The game condition contains the state of the board as a 2d array.
o Draw Game state: The draw game state is a function that causes both the both the
board be draw and the pieces being displayed on their relative positions.
• Pieces: This is responsible for spawning all the pieces on the board.
o Color: This specifies whether a piece would be Black or White.
o King: This refers to the king piece and contains its image. Its movements are defined
in the pieces movement. The logic for checkmate is dependent on this piece as if its
path is blocked by an opponent’s piece.
o Queen: This refers to the queen piece and contains its image. Its movements are
defined in the pieces movement
o Pawn: This refers to the pawn piece and contains its image. Its movements are
defined in the pieces movement
o Knight: This refers to the knight piece and contains its image. Its movements are
defined in the pieces movement
o Bishop: This refers to the bishop piece and contains its image. Its movements are
defined in the pieces movement
• Movement: This contains the logic which allows the pieces to move as they would move in a
real chess game.
Page 19 of 145
o
•
•
•
Pieces movement: This defines what moves are valid for a certain with respect to
their corresponding position at the board.
o Move function: This function allows the pieces to be moved by a mouse function
which lets a piece on a square to be selected by clicking. Then a piece could be moved
by clicking on another square. This square’s position is checked from position to check
for validation of move and then finally the piece is moved.
Elimination: This contains the logic which must be followed in order to eliminate a piece.
o Capture method: This allows a piece to take an opponent’s piece by first selecting a
piece and moving it via the move function. If the move is valid and that square is
already occupied by an opponent’s piece (except king) that piece would be
eliminated.
Termination: This defines all the cases which could lead to the termination of the game.
o Checkmate: This form of termination checks if ones king is in danger and no further
move could lead to its rescue.
o Draw: This checks for a few cases such as Stalemate, Dead-position, and Fifty-move
rule. The first two checks if the game in unchecked state can’t proceed as there are
no legal moves that could be made from now or no legal moves that could lead to a
checkmate. While the third case checks if no pawn has been moved or no capture
has been made during last 50 moves. All of these would result in a draw.
o Resign: This allows one of the players to resign the game, so the other player is
granted a win automatically.
o Timeout: This form of termination is only applicable in time-modes. As one of the
players runs out of time the other player is automatically declared as winner.
Player: This is responsible for creating two players to allow them to compete in a game.
o Player Class: The player class defines the attributes of a player and the methods they
can access while playing a game.
o Piece-type allocated: This decides what color of pieces would be allocated to each
player before the start of a game.
Info:
This is an informative screen which contains all the necessary information the user would require in
order to play the game.
•
•
Pieces Info: This contains information about all the pieces. Their movements and other
relevant information like promotion of a pawn, castling etc. This will also consist of images
which will graphically represent movements of different pieces.
Game Rules: This contains all the rules which have to be followed in order to carry out a valid
game. This would consist of information about different forms of termination, time-modes. It
will also contain information how the user can play the game like how they can select a piece,
how they can move a piece, and how can they capture an opponent’s piece.
Page 20 of 145
Quit:
This is responsible for zoning out of the game.
•
Terminating the game: This causes the game to terminate or zone out from either game loop or
the info page.
DESIGN OF USER INTERFACE
The design is to the stakeholder’s specification. A modern UI that is simplistic but has the functionality
there, bold fonts and high contrast color scheme.
Background:
The current background on the mockup is a just a parchment background to fill the screen. It will be
changed to an image of a chess board with pieces to fit the theme of the game.
Page 21 of 145
Buttons:
The buttons are simple and easy to use. The names quite explain the purpose of the button. “Play” will
start a chess game for you while the “Info” button will take you to a screen which contains all the
information about pieces and game rules which the player would need to know to play the game. “Quit”
will terminate the game.
Usability Feature:
The background of the main menu screen will allow for easy visibility of the text and buttons so the user
can easily read and advance past the main menu. The buttons and the text they hold will also be made
to allow easy readability using contrasting colors, in addition to this when the user brings the cursor on
the button it will highlight the button with another high contrasting color so making it easier for the user
to select the right option. The color of buttons and background is set as it will allow people with color
blindness to access the game without any difficult. So, due to this color like red, green, yellow, and blue
are not included in the colors used for the main menu screen.
DESIGN OF GAME SCREEN
Page 22 of 145
Background:
The background of the game screen would be a seamless image with patterns like wood. This would give
an imagery as if the chess board is on an actual table made of wood.
Chess board:
The chess board would consist of alternating squares of colors saddle brown and sandy brown. These
colors have been chosen as they are very high contrast and people even people with color blindness
won’t face any problem or inconvenience while playing this game.
Time counters:
The time counters would be at top left and bottom right of the screen. These would only appear in the
time mode. The color scheme would be black and white for the time counter as it is high in contrast.
Player icon:
The player icon would consist of the player’s piece color and either just named player number or their
name. This icon would be highlighted when the relative player’s turn starts.
Flag:
Next to each players icon there would be an icon of a flag. The player can click on this icon to resign the
game once they confirm it on the pop screen which appears when the flag icon is pressed.
Usability features:
The background of the game screen would help the user by allowing easy visibility of the buttons and
the chess board. This allows them to easily proceed with the game. In addition to this the high contrast
color scheme of the chess board with different shades of brown will allow people with color blindness to
experience the gameplay without any inconsistencies. The player icon would help the players by
indicating their turns and also distinguishing which piece color was allocated to them. The flag icon will
allow the user to resign the game while the time counter will help the players to keep track of their
remaining time. So, on whole providing all the features which will allow the user to interact with the
game without any difficulty and at the same time providing them a great gaming experience.
Page 23 of 145
TEST DATA
KEY VARIABLES
NAME
VARIABLE IDENTIFIER
DATA TYPE
PURPOSE
Display Width
display_width
Integer
Defines how wide the display
screen would be.
Display Height
display_height
Integer
Defines the height of the display
screen.
Board Width
board_width
Integer
Defines how wide the chess board
would be.
Board Height
board_height
Integer
Defines the height of the chess
board.
Square size
SquareSize
Integer
Defines the size of each square on
the chess board.
Dimensions
Dimensions
Integer
This specifies number of
dimensions of the chess board.
Mouse Position
Mouse
Integer
This refers to the current position
of the mouse on the display screen.
Game Screen
gameScreen
Object
This refers to game screen which
consist of board and pieces.
In Game loop
inGame
Boolean
This checks whether the player is in
game loop or not
Play
Play
Boolean
This checks whether the play has
started or not.
Board
board
2d Array
This contains the state of board on
the start of the game.
Square Selection
SelectedSquare
Integer
This refers to the square which the
player has selected by clicking.
Start move
WhiteToMove
Boolean
This checks whether the white
pieces are allowed to move or not.
Player Click
PlayerClicks
List
This refers to the positions where
the player clicked so a move log
can be created.
Columns
Col
Integer
This refers to the number of the
columns on the chess board.
Rows
Row
Integer
This refers to the number of the
rows on the chess board.
Location
Location
Integer
This refers to the location of a
piece on a chess board.
Page 24 of 145
Board colors
Color
String
This refers to the colors we will use
for our board.
Images
IMAGES
Dictionary
This refers to all the images of
pieces that we need for the game.
Clock
timer
Time
This refers to the amount of time a
player is left with to complete the
game.
Turn
WhiteToMove
Boolean
This refers if its turn for a white
piece to move or not.
Directions
directions
tuple
This refers to the directions a
particular can move to.
End Colum
endCol
integer
This refers to horizontal position a
piece will end on after being
moved.
Start Colum
startCol
integer
This refers to horizontal position a
piece is currently on before being
moved.
End Row
endRow
integer
This refers to vertical position a
piece will end on after being
moved.
Start Row
startRow
integer
This refers to vertical position a
piece is currently on before being
moved.
Colors
colors
list
This refers to colors which would
combine to produce the board.
Valid Moves
validMoves
list
This refers to set of valid moves a
piece can make corresponding to
its current position.
Move made
moveMade
Boolean
This checks if a move is made or
not so turns can change.
Page 25 of 145
CLASS DIAGRAM
Page 26 of 145
The GameCondition class is responsible for drawing the board, changing the turns, and checking for
checkmate.
The board refers to a 2d array that will hold the state of the board. The WhiteToMove attribute is
responsible for switching the turns. When it is true the white pieces would be allowed otherwise it is the
turn for black pieces to move. The moveLog would be a list of all moves made. checkMate and
stalleMate are Boolean the game would end whenever one of these are true. They are initially set as
false. The WhiteKingLocation and BlackKingLocation holds the initial row and column value of
respective king piece at the start of the game. These would be updated throughout the game when king
piece would be moved.
The makeMove() is to make a move on the board while undoMove() would undo a move. The
getValidMoves() would return all the valid moves for a piece. The squareUnderAttack() would check
whether a piece is under attack or not while inCheckmate() would check if the piece under attack is a
king piece or not.
The Move class is responsible for moving pieces.
The startRow, startCol, endRow and endCol refer to the starting and ending rows and columns of a
piece. PawnPromotion is Boolean when it is true it will ask the player to promote the pawn to a higher
ranked piece. It would be initially set as false.
The getAllPossibleMoves class is for generating all the possible moves for all the different pieces.
The row and column refer to how piece can be moved on the board in terms of the row and column of
their current position. The directions refer to different moves that can be on a piece in terms of its x and
y coordinates on the board, moves is a list of moves that can be made.
The getPawnMoves() returns all possible moves for a pawn piece, the getRookMoves() returns all
possible moves for a rook piece, the getBishopMoves() returns all possible moves for a bishop piece,
The getKnightMoves() returns all possible moves for a knight piece, the getQueenMoves() returns all
possible moves for a queen piece and the getKingMoves() returns all possible moves for a king piece. All
of these moves are without considering checkmate.
Page 27 of 145
ALGORITHMS
GAME MODE SELECTION
The game mode selection algorithm checks which game mode
to initialize when the player decides to start a game after
pressing the play button.
The game mode offers the player an option to select between
two game modes. The two games modes are described as
“normal mode” and “time-mode”. The player then has to
select one of them by pressing on buttons labelled after their
names.
If the user selects normal mode a game of chess without any
time restriction would be initialized. In case the player selects
time-mode then they would be further required to select an
amount of time provided there. After the user has selected
one time slot then a game would be initialized with each
player give the selected time slot.
Page 28 of 145
MOVING A PIECE
The moving a piece algorithm checks when a
player wants to move their piece on any
position on the board are they allowed to do
so or not.
When the player selects a position to be
moved the algorithm then goes to the
validation algorithm to check if the move is
valid corresponding to the rank of the piece.
If valid then checks whether the selected
position is already occupied by another piece
or not. If not occupied then the position is
updated on the screen.
In case it is occupied then it determines
whether the piece occupying the position
belongs to player themselves or their
opponent.
If the piece belongs to player themselves then
the user is asked to select another position
and this process repeats.
In case the piece belongs to opponent the
opponent’s piece is eliminated and the
position of the piece is updated.
Page 29 of 145
PROMOTION
The promotion algorithm checks that whether a pawn
can be promoted to a piece of higher rank or not.
For a pawn to promote they have to reach the
furthest position on the board which is the same row
where the opponent’s higher rank pieces are at the
start of the game.
Every time a pawn is moved the algorithm checks if
the position it has been moved would result that it
can’t move further. If not then the game proceeds as
normal.
In case it has then the user is supposed to input the
type of piece they want it to promote to. This input is
carried about just clicking on the icons of the piece
they would like it to promote to these icons would
appear in a pop-up box.
After the user has selected the type of the piece, they
want the pawn to promote to. The pawn is replaced
by that piece and updated on the screen.
Page 30 of 145
CHECKMATE
The checkmate algorithm is the quite important as it is
the main aim of the game. Whenever a piece is moved it
checks whether the game is in checkmate state or not.
In case it’s not the game would proceed as normal. But
if it is in the state of checkmate the algorithm checks if
any legal moves can result in this state to change.
If a move can be made to counter the checkmate, then
the player is required to make a move so the game can
proceed. This process would be repeated after every
move.
If no legal move could be made to counter the
checkmate, then the other player is declared winner and
the game terminates.
Page 31 of 145
FIFTY MOVE RULE
This algorithm checks for a special case
which results in the game to draw.
Whenever a piece is moved it is
recorded into a move log. The algorithm
checks if one of the two conditions
were true for the last 50 moves.
One condition is to check whether in
the last 50 moves a pawn has been
moved or not. If moved the game can
proceed otherwise either player can
claim a draw.
The second condition is whether in last
50 moves a piece has been eliminated
or not. If a piece has been eliminated
the game can proceed otherwise as
similar to the first case the either player
can claim a draw.
When player claims draw the game
would be declared as drawn and then it
would terminate.
Page 32 of 145
GUIDING POINTER
This algorithm shows the
process which would be
followed in order to provide
the player aid of guiding
pointer.
Whenever a player selects a
piece the valid moves for that
piece corresponding to its rank
is checked. After this it checks
whether a piece is present on
any of the positions it can
move to.
If not, then just highlight all the
squares it can move to green. If
a piece is present, then it
checks whether the piece
belongs to the player
themselves or their opponent.
In case own piece is present
leave that position
unhighlighted while highlight
other positions it can still move
to as green.
If an opponent piece is present
then highlight that square as
red whilst other squares would
still be highlighted green.
Page 33 of 145
LINKING THE ALGORITHMS
Whenever a piece is selected for moving the guiding pointer algorithm is applied to highlight all the
valid moves for that certain piece are highlighted. When the square to be moved to for this piece is
confirmed then the moving a piece algorithm checks whether this is a valid move which was highlighted
due to the guiding pointer. If valid then the move is made. After the move is made it is placed into move
log and other algorithms are applied now. If not valid then the player is expected to make an alternative
move.
If the piece which was moved was a pawn then the promotion algorithm is called to check whether
promotion for pawn is applicable or not. If applicable then the user is asked for a piece type be
promoted to. Else the move was just a normal move and added to the move log straight away.
If the piece moved was not a pawn then the fifty-move rule algorithm is called. It then checks if no
pawns are moved in the last 50 moves and no eliminations took place in the last 50 moves. If this is true
then either player is allowed to claim a draw and if claimed the game would end as draw under fiftymove rule else the game would proceed also if fifty-move rule is not applicable then the game would
proceed as normal.
When any piece is moved then the checkmate algorithm is called. The algorithm would check if one of
the kings pieces is under attack. If this is true then all valid moves are retrieved to check if a move can be
made to get the king out of check. If this is case then the player is expected to make a move, but this
time guiding pointer algorithm would only highlight the moves which can put the king out of check and
the moving a piece algorithm would only allow these moves. In case there are no legal moves that can
be made to get the king out of check then the win would be awarded to the player who put the opposite
king under checkmate and the game would be terminated.
Page 34 of 145
TEST DATA FOR APLHA TESTING
These tests would be carried out during the development stage so any inconsistencies within the code
logic could be spotted and fixed before the game is ready for the user to test so, then it can be finally
released. All of these tests would be carried out individually after one stage has been completed. They
are likely to be carried out in the order they are listed as during the development one stage would build
upon the previously developed functionality.
TEST
NUMBER
TESTING
EXPECTED
OUTCOME
JUSTIFICATION
TEST DATA
1
Checking if the main
menu screen loads
properly and the
buttons function as
intended.
The background image
is loaded properly, and
the buttons are
centrally aligned,
when pressed takes to
another screen.
If main menu
doesn’t function
properly the user
won’t be able to
navigate through
the game.
N/A
2
Checking if a chess
board of
proportional squares
of alternating
colours is built.
A chess board of 8
columns and 8 rows of
is made and
alternating squares
should have opposite
colours.
To check if the
board is built
correctly before
pieces are added
on.
N/A
3
Checking if the
pieces are loaded on
the board in the
right positions.
The pieces should be
loaded on the board
as they would appear
in real before the start
of a game. And they
should also occupy a
hole square.
The pieces should
be in right order
before we progress
and try to move
them.
N/A
4
Checking if the
pieces can move on
different squares on
board and occupy
the whole square.
When a piece is
selected by clicking it
should be moved to
the square selected by
the user.
Need to ensure
that the pieces can
to different
squares before
allowing them to
eliminate a piece.
N/A
5
Check if a piece can
eliminate an
opponent’s piece.
When a piece is
moved to a position
which is already
occupied by an
opponent’s piece that
piece should
disappear from
screen.
For the game to
proceed it is
necessary pieces
are allowed to
eliminate
opponent’s piece.
N/A
Page 35 of 145
6
Checking that the
pieces are only
allowed to make
valid moves.
When a piece is asked
to move to a position
check if that move is
valid according to
chess rule’s in case not
some sort of
indication to highlight
that the move can’t be
made.
This is essential as
each piece has a
set of moves
according to their
ranks and also
relative to current
state of the game.
N/A
7
Testing that it checks
for checkmate after
every move and in
case a checkmate is
spotted some
indication is made.
If a move of any piece
has caused game to be
in checkmate state. In
case it is then highlight
the king’s piece red to
indicate this state.
This is the main
N/A
purpose of a chess
game, so the game
wouldn’t be able to
produce a result if
checkmate isn’t
checked.
8
Testing if the game
terminates by other
forms such as resign,
stalemate, and fiftymove-rule.
The game should
terminate in all cases
and win should be
awarded if one player
resigns else in other
two causes it’s a draw.
This is necessary as
in an actual game
the game would
terminate if any of
these takes place.
Fifty moves
without taking a
piece.
8
Checking if the flag
icon completely
functional.
A pop screen should
appear which confirms
the user wants to
resign once the icon is
pressed.
If this doesn’t
function the player
won’t have the
option to resign.
N/A
9
Testing if the guiding
pointer is
functioning properly.
Once a piece has been
selected the squares it
can move to should be
highlighted.
This feature has to
be functional for a
player to check
what valid moves
could be made.
N/A
10
Testing if the time
counters functions
properly.
The time counter
should start with the
time selected after the
first moves of each
player is done. The
counter should go
down until the player
makes a move so it
should stop and
counter for the other
player should begin.
For a game in time
mode to work
smoothly it is
essential that the
clock operates
properly else the
game won’t
function properly.
5 minutes.
Stalemate
10 minutes.
15 minutes.
Page 36 of 145
11
12
Testing if the time
mode game
terminates if one of
players runs out of
time.
If a player runs out of
time in time modes
game then other
player should be
awarded a win and the
game should
terminate.
It is necessary that
game is
terminated, and
win is awarded to
one of the players
as one of them
runs out of time as
that is what would
happen in actual
game of chess.
5 minutes.
Checking if the
player name is
displayed once they
have been entered
before the game.
The player icon should
display the name
entered by the user.
This is necessary as
it will allow the
user to know their
color of pieces and
also giving an
indication once
their turn starts.
Player1: Hassan
10 minutes.
15 minutes.
Player2: Ali
POST DEVELOPMENT TEST PLAN
After the coded solution is completed these tests would be carried out to check if the final product is
like what it was described in the analysis and design stage. The stakeholders would be one of the few
users to test the game before it is finally ready to release.
MAIN MENU
Test
Number
Testing
Expected Outcome
Justification
1
The background image
for main menu screen is
loaded properly in line
with proportions of
screen size.
The background image for the
main menu screen fits the whole
screen and no parts of the screen
are left blank.
If the background image is
not loaded properly the
main screen would look
inconsistent and would
make it less appealing.
2
The buttons are of same
size and on the main
screen are centrally
aligned.
The buttons should have same
size and should be in the center
of screen and vertically from a
column.
If the buttons are not
centrally aligned and
different sizes the main
screen would look
inconsistent.
3
The buttons highlight
when the cursor is
placed on them.
The buttons are highlighted with
a different color when the cursor
is brought onto the button.
The buttons highlighting
will indicate the user which
button they are currently
on.
Page 37 of 145
4
The game starts when
“PLAY” button is
pressed.
A game of chess should start
when the “PLAY” button is
pressed.
If the “PLAY” button
doesn’t initiate the game
the user would be unable
to play the game.
5
The info screen loads
when the “INFO” button
is pressed.
The player should be navigated
to info screen when “INFO”
button is pressed.
For the user to be able to
access info page the “INFO”
button should function
properly.
6
The game is terminated
when “QUIT” button is
pressed.
The player should exit from the
game when “QUIT” button is
pressed.
For the user to exit the
game the “QUIT” button
should function properly.
BOARD SETUP
Test
Number
Testing
Expected Outcome
Justification
1
The board contains 64
squares of alternating
color square next as an 8
by 8 grid.
An 8 by 8 grid of 64 squares
loads with alternating squares
of light and dark colors.
The actual chess board setup
is like this so for a proper
game to be played the board
setup should be accurate.
2
Both players are given 16 Both players are allotted 16
pieces in the start of the pieces of one color before the
game.
start of the game.
This is necessary as both
players are allotted 16 pieces
in an actual game of chess.
3
Each player has 8 pawns
and 1 king and 2 of
queen, bishop, knight,
and rook.
The specified number for
different pieces is loaded on the
board.
For a proper game of chess
to take place each player
should be allotted these
number of different pieces.
4
The pieces are spawned
at their specific position.
The pawns should take all
squares in the row of second
column from each side. Rook on
corners of first row of either
side followed by bishop, knight,
king, and queen.
For the game to imitate a
real chess game the pieces
should be spawned at their
specified positions.
PAWN MOVEMENTS
Test
Number
1
Testing
The pawn can move two
squares vertically
forward when in starting
position.
Expected Outcome
Justification
The pawn should be able to move In chess a pawn is allowed
two squares forward vertically
to move two squares
when in its starting position.
forward when it is at its
starting position.
Page 38 of 145
2
The pawn can move one
square vertically forward
when in starting
position.
The pawn should be able move
one square forward vertically
when in its starting position.
In chess a pawn is allowed
to move one square
forward when it is at its
starting position.
3
The pawn can’t move
two squares vertical
after starting position.
The pawn should only move one
square forward vertically when
not at its starting position.
In chess a pawn is allowed
to move one square
forward after it has moved
from its starting position.
4
The pawn can only
eliminate enemy piece
one square diagonally.
The pawn should eliminate an
enemy piece if it is one square
diagonally forward.
In chess a pawn can only
eliminate an enemy piece if
it is one square diagonally
forward to the current
position.
ROOK MOVEMENTS
Test
Number
Testing
Expected Outcome
Justification
1
The rook can move
vertically to any number
of squares if no piece in
path.
The rook should be able to move
any number of squares vertically
in a column if no other piece in
between.
In chess it is valid for a
rook to move any number
of squares vertically in the
same column.
2
The rook can move
vertically to any number
of squares if no piece in
path.
The rook should be able to move
any number of squares
horizontally in a row if no other
piece in between.
In chess it is valid for a
rook to move any number
of squares horizontally in
the same row.
3
The pawn can eliminate
an enemy piece
horizontally.
The rook should be able to
eliminate an enemy piece if it is
in the same row and no pieces in
between.
In chess a rook can capture
an enemy piece
horizontally if no pieces in
between.
4
The pawn can eliminate
an enemy piece
vertically.
The rook should be able to
eliminate an enemy piece if it is
in the same column and no
pieces in between.
In chess a rook can capture
an enemy piece vertically if
no pieces in between.
5
The rook can’t jump
over its own piece.
The rook shouldn’t be able to
jump over an ally piece.
In chess a rook piece isn’t
allowed to take a square
by jumping over an ally
piece.
6
The rook can’t jump
over an enemy piece.
The rook shouldn’t be able to
jump over an enemy piece.
In chess a rook piece isn’t
allowed to take a square
by jumping over an enemy
piece.
Page 39 of 145
BISHOP MOVEMENTS
Test
Number
Testing
Expected Outcome
Justification
1
The bishop can move
diagonally right to any
number of squares if no
piece in path.
The bishop should be able to
move any number of squares
diagonally to right if no pieces in
between.
In chess a bishop can move
any number of squares
diagonally to right if no
pieces in between.
2
The bishop can move
diagonally left to any
number of squares if no
piece in path.
The bishop should be able to
move any number of squares
diagonally to left if no pieces in
between.
In chess a bishop can move
any number of squares
diagonally to left if no
pieces in between.
3
The bishop can only
eliminate enemy piece
diagonally.
The bishop should be able to
eliminate an enemy piece
diagonally if no pieces in
between.
In chess a bishop can
eliminate an enemy piece
diagonally to any direction
if no other pieces in
between.
4
The bishop can’t jump
over its own piece.
The bishop shouldn’t be able to
jump over its ally piece.
In chess a bishop piece
isn’t allowed to take a
square by jumping over an
ally piece.
5
The bishop can’t jump
over an enemy piece.
The bishop shouldn’t be able to
jump over an enemy piece.
In chess a bishop piece
isn’t allowed to take a
square by jumping over an
enemy piece.
KNIGHT MOVEMENTS
Test
Number
Testing
Expected Outcome
Justification
1
The knight can move two
squares vertically and
one square horizontally
from its position.
The knight should be able to
take a square such that its
path forms a vertical L.
In chess a knight can only
move by moving one square in
one direction in two squares in
the other direction.
2
The knight can move two
squares horizontally and
one square vertically
from its position.
The knight should be able to
take a square such that its
path forms a horizontal L
shape.
In chess a knight can only
move by moving one square in
one direction in two squares in
the other direction.
3
The knight can only
eliminate enemy piece
with its valid moves.
The knight should be allowed
to eliminate an enemy piece if
it is on square which the
knight can take legally.
If an enemy piece exists on a
square where the knight can
move to legally then the knight
should be allowed to eliminate
that piece.
Page 40 of 145
4
The knight can jump
over its own piece.
The knight should be allowed
to take a square for which it
has to jump over its ally piece.
In chess, knight is the only
piece which could take a
square by jumping over its ally
piece.
5
The knight can jump
over an enemy piece.
The knight should be allowed
to take a square for which it
has to jump over its enemy
piece.
In chess, knight is the only
piece which could take a
square by jumping over an
enemy piece.
QUEEN MOVEMENTS
Test
Number
Testing
Expected Outcome
Justification
1
The queen can move
vertically to any number
of squares if no piece in
path.
The queen should be able to
move any number of squares
vertically if no piece in
between.
In chess it is valid for a queen
to move any number of
squares vertically in the same
column if no pieces in
between.
2
The queen can move
horizontally to any
number of squares if no
piece in path.
The queen should be able to
move any number of squares
horizontally if no piece in
between.
In chess it is valid for a queen
to move any number of
squares vertically in the same
row if no pieces in between.
3
The queen can move
diagonally right to any
number of squares if no
piece in path.
The queen should be able to
move any number of squares
diagonally to right if no piece
in between.
In chess a queen can move any
number of squares diagonally
to right if no pieces in
between.
4
The queen can move
diagonally left to any
number of squares if no
piece in path.
The queen should be able to
move any number of squares
diagonally to left if no piece in
between.
In chess a queen can move any
number of squares diagonally
to left if no pieces in between.
5
The queen can’t jump
over its own piece.
The queen shouldn’t be able
to take a square for which it
has to jump over its ally piece.
In chess a queen piece isn’t
allowed to take a square by
jumping over an ally piece.
6
The queen can’t jump
over an enemy piece.
The queen shouldn’t be able
to take a square for which it
has to jump over an enemy
piece.
In chess a queen piece isn’t
allowed to take a square by
jumping over an enemy piece.
7
The queen can eliminate
an enemy piece with its
valid moves.
The queen should be to
eliminate an enemy piece if it
exists on a position which the
queen could move to by a
valid move.
In chess a queen is allowed to
eliminate an enemy piece it is
on square which the queen can
move to by a valid move.
Page 41 of 145
KING MOVEMENTS
Test
Number
Testing
Expected Outcome
Justification
1
The king can move one
square vertically from its
position.
The king should be able to move
one square vertically in the same
column if it doesn’t put it under
checkmate.
In chess a king is allowed to
move one square vertically
if it doesn’t put it under
checkmate.
2
The king can move one
square horizontally from
its position.
The king should be able to move
one square horizontally in the
same row if it doesn’t put it
under checkmate.
In chess a king is allowed to
move one square
horizontally if it doesn’t put
it under checkmate.
3
The king can move one
square diagonally from
its position.
The king should be able to move
one square diagonally in any
direction if it doesn’t put it under
checkmate.
In chess a king is allowed to
move one square
diagonally if it doesn’t put it
under checkmate.
4
The king can eliminate a
piece by its valid moves.
The king should be able to
eliminate an enemy piece by a
legal move if it doesn’t put it
under checkmate.
In chess a king is allowed to
eliminate an enemy piece it
is on square which the king
can move to legally and
won’t put the king under
check.
7
The king can’t make a
valid move which puts it
under checkmate.
The king shouldn’t be able to
make a move such that it will put
the king under checkmate.
In chess it is illegal to make
a move which would put
own king under checkmate.
GUIDING POINTER
Test
Number
Testing
Expected Outcome
Justification
1
All the valid moves for a
pawn are highlighted
when a pawn selected.
When a pawn piece is selected all
the squares it can move to legally
should be highlighted.
For the player to know the
valid moves for a pawn
they should be highlighted.
2
All the valid moves for a
rook are highlighted
when a pawn selected.
When a rook piece is selected all
the squares it can move to legally
should be highlighted.
For the player to know the
valid moves for a rook they
should be highlighted.
3
All the valid moves for a
bishop are highlighted
when a pawn selected.
When a bishop piece is selected
all the squares it can move to
legally should be highlighted.
For the player to know the
valid moves for a bishop
they should be highlighted.
4
All the valid moves for a
knight are highlighted
when a pawn selected.
When a knight piece is selected
all the squares it can move to
legally should be highlighted.
For the player to know the
valid moves for a knight
they should be highlighted.
Page 42 of 145
5
All the valid moves for a
queen are highlighted
when a pawn selected.
When a queen piece is selected
all the squares it can move to
legally should be highlighted.
For the player to know the
valid moves for a queen
they should be highlighted.
6
All the valid moves for a
king are highlighted
when a pawn selected.
When a king piece is selected all
the squares it can move to legally
should be highlighted.
For the player to know the
valid moves for a king they
should be highlighted.
7
All the valid which would
put king under
checkmate are not
highlighted.
A move for any piece that could
put their king under check
shouldn’t be highlighted when
that piece is selected.
Moves that puts the king
under checkmate are illegal
and therefore not be
highlighted.
8
When in checkmate
moves which would not
take the game out of
checkmate are not
highlighted.
When the game is under
checkmate all moves which
would retain the checkmate
shouldn’t be highlighted.
Moves that retain the
checkmate of own king are
not valid so shouldn’t be
highlighted.
GAME OVER
Test
Number
Testing
Expected Outcome
Justification
1
The game ends when
checkmate is true, and
no legal moves could be
made.
The game should end when one
of kings is under checkmate and
there are no legal moves to tackle
it.
If no legal moves are
available to put king out of
check then the game should
end.
2
The game ends when
stalemate is true.
The game should end when there
are no legal moves available
which will put either under
checkmate.
If either player poses no
moves that could put
opposite king under check
then the game should end.
3
The game over screen
loads when the game
ends.
When game has been ended by
either case the game over screen
should be loaded.
The game over screen
should load to notify the
players that the game has
ended.
4
The draw message is
displayed on the game
over screen when game
ends via stalemate.
If a game has ended by stalemate
a message should appear on
game over screen which confirms
that game is drawn under
stalemate.
If game has ended via
stalemate then the players
should be notified of this.
5
The winner message is
displayed on the game
over screen when game
ends via checkmate.
If the game has ended by
checkmate then the winner
announcing message should
appear on the game over screen.
If the game ends by
checkmate then winner
should be announced so the
players know who won.
Page 43 of 145
PAWN PROMOTION
Test
Number
Testing
Expected Outcome
Justification
1
The pawn can be
promoted a higher
ranked piece if it reaches
the farthest position on
board.
If a pawn has reached the
farthest position then it should
be allowed to be promoted to a
higher ranked piece.
In chess if a pawn piece
reaches the end row of the
board then it should be
promoted a higher ranked
piece.
2
The player is presented
with a selection box
which have 4 options to
choose from.
When a pawn is to be promoted
the player should be presented
with 4 options(Queen, Knight,
Bishop, and Rook) to choose
which piece type they want the
pawn to promote to.
For the player to choose
which piece type they want
the pawn to be promoted to
them should be presented
with a choice box to confirm
their choice.
3
The pawn is promoted to
a queen piece if queen
option is selected from
the selection box.
When the player has chosen the
queen option from the selection
box the pawn should be replaced
with a queen piece on the board.
Once the player has chosen
which type of piece they
want the pawn to be
promoted to the pawn should
be replaced with the chosen
piece type.
4
The pawn is promoted to
a bishop piece if bishop
option is selected from
the selection box.
When the player has chosen the
bishop option from the selection
box the pawn should be replaced
with a bishop piece on the board.
Once the player has chosen
which type of piece they
want the pawn to be
promoted to the pawn should
be replaced with the chosen
piece type.
5
The pawn is promoted to
a rook piece if rook
option is selected from
the selection box.
When the player has chosen the
rook option from the selection
box the pawn should be replaced
with a rook piece on the board.
Once the player has chosen
which type of piece they
want the pawn to be
promoted to the pawn should
be replaced with the chosen
piece type.
6
The pawn is promoted to
a knight piece if knight
option is selected from
the selection box.
When the player has chosen the
knight option from the selection
box the pawn should be replaced
with a knight piece on the board.
Once the player has chosen
which type of piece they
want the pawn to be
promoted to the pawn should
be replaced with the chosen
piece type.
Page 44 of 145
SOUND FEATURES
Test
Number
Testing
Expected Outcome
Justification
1
The background music
keeps playing until the
game finishes.
When the game has started the
background music should start to
play and it should be kept playing
until the game ends.
The background music
during game would
enhance the gaming
experience and make the
game more appealing.
2
The piece movement
sound is played
whenever a piece is
moved.
When a piece has been moved
then the piece movement sound
should be played.
This sound would notify the
player that the piece has
been successfully moved.
3
The promotion sound is
played when a pawn is
promoted a higher
ranked piece.
When a pawn has been
successfully promoted to a higher
ranked piece the promotion
sound should be played.
This sound would notify the
player that the pawn has
been successfully promoted
to a higher ranked piece.
4
The game over sound is
played when the game
ends by any form of
termination.
When a game has ended via any
form the game over sound should
be played.
This sound will notify the
player that the game has
ended, and no moves could
be made now.
SIGN OFF PROPOSAL
Lastly, I took the final design mock-up screens, explained the overall way I will tackle the problem. Then
went on to ask them how they felt about it and feel they think any changes are required else to sign off.
Sayem
Ali
I loved the design, and I am very satisfied with
description of the solution as it is very detailed,
clear, and consistent. The mockup screens
suggest that the finished interface would be a
true reflection of what was described in analysis
stage. I am happy with you to proceed with the
developing stage and looking forward to the
finished project.
I think everything looks like it is designed to a
high standard and that you can start developing.
The way you described the solution also seems
like it’s the right way to tackle making this chess
game. The interface looks very attractive and
easy to use from the mockup screens you showed
so can’t wait to see the game when it’s
completed.
Sign off e-signatures | Signed and dated
Page 45 of 145
DEVELOPING THE CODED SOLUTION (“THE DEVELOPMENT STORY”)
Creating a virtual environment:
To start my development, I first had to make a virtual environment to store all libraries, frameworks,
and extensions I was going to use. This is so everything is self-contained and in later deployment it can
be easily transferred over to the server.
This console command is to initialize the virtual environment in a folder called .venv in the development
folder using python 3.
Visual studio recognizes that I have created a virtual environment and asks me if I want to create a
folder to store it in, which I do since there needs to be a permanent store for libraries.
Then I checked if it had created the folder in the right location, which it had. Now every time I want to
install a library or use a command from one, I can reference this file to launch it from
Then I downloaded the libraries I needed for the project using the pip command. So now my setup was
ready, and I can start the project.
Starting the project:
CREATING THE MAIN MENU-13/10/2021
I started my project by building my Main menu. The main menu will consist of basically three options
which include Play, Info, and Quit. So, the main menu would be a rectangular screen with three
rectangular buttons lined in the center of
the screen. These buttons would produce
an output when the user clicks on them
using a mouse. For this I named this file
Main and imported pygame to create
these buttons and registering mouse
clicks. I also imported time which would
be for later use when we develop the
clock for time-modes.
Page 46 of 145
Then to start with my main menu screen
I globally declared two variables named
screen_width and screen_height. The
screen_width will define how wide the
screen would be while the height of the screen would be defined by screen height.
Then to create the screen area I created a variable called gameDisplay it uses the pygame module
‘display’ to create the display screen which uses the set_mode funstion which takes values which we
passed on to display_height and display_width.
Then to create the buttons on the screen I made a function called button which takes parameters to
create the button. In addition to that it has two functions called mouse and click, mouse keeps track of
where button would be relative to the display screen while click will cause the button to be pressed. I
have to pass on the x-coordinate, y-coordinate, width of the button, height of the button, it’s primary
color and the hover color (the color it changes to when the cursor is on the button). These parameters
all together produce a rectangular button.
Then to check the position of the button and draw a rectangle for it I have applied a condition which
makes sure that some position vectors, widths, and heights are passed on. To draw small text, I have
used the same format as before. The variable smallText would define the font style and size which in
this case is Times new roman and 20. The text on the button would be centrally aligned this is achieved
by halving the width and the height of the button. The text_objects function is for the text in the box. It
has been passed two parameters msg which would be the text in the box and smallText which would be
the format of font in the box.
Page 47 of 145
Now to finally implement it I have made a function called main_menu. This function will initialise the
main menu when called.
I have created another variable called largeText. This defines the font style and size of the large text on
the main menu screen. I have set font style as arial and font size to be 40.
This will fill the gameDisplay with gray colour.
Now to navigate through the game I created buttons by calling button function. I have named them as
“PLAY,” “INFO,” and “QUIT.” The “PLAY” button will take us to the game_loop where we can play the
game. “INFO” will take us to the information page while “QUIT” would simply close the game. All the
buttons would have the same width and height which are 125 and 50, respectively. All buttons would be
aligned in the centre of screen vertically below each other. I have set the colour brown for all of them,
and the highlighting colour is same as well for all of them which is blue.
The main_menu function is called so now the main menu screen should be initialised.
Test
number
1
(Video1)
Testing
Description
Checking the buttons
load on their specified
position and highlight
when cursor placed on
them.
Expected Outcome
Justification
Actual Outcome
The buttons would be
centrally aligned and
would highlight when
the cursor is placed on
them.
The buttons
highlighting will let
user known which
button are they
about to click on.
Successful test as
the buttons were
at the right
position and
highlighted when
cursor placed on
them.
Actions
Required
N/A
Page 48 of 145
MAIN MENU SCREEN - PROTOTYPE 1
Now as the main menu screen is implemented successfully, I have decided to replace the background
with an image which suits the theme of the game. I have used the load function from image module of
pygame to load this image.
The following image shows the state of the main menu screen after the background change was
implemented.
Page 49 of 145
MAIN MENU SCREEN - PROTOTYPE 2
To make the game more appealing I have decided to change the font style of the buttons, for this I have
downloaded a free to use font style which looks much more appealing.
Page 50 of 145
Likewise, I have changed the font style for large text, so the game looks much more appealing.
The image shows the state of main menu screen after following changes were implemented.
MAIN MENU SCREEN - PROTOTYPE 3
Page 51 of 145
CREATING THE CHESS BOARD-27/10/2021
As now I have completed the menu screen, I can work on towards building the actual game. For this I
have decided to start with my chess board. The board would consist of 8*8 squares. Alternating squares
would have different colours. For all the gameplay related stuff such as game condition and movement I
have created a separate file called GameDesign contains a class called GameCondition. This class will
contain the setup of the board. The board is setup to be an array of 8*8. The board is set like a chess
board in real life with the pieces placed on it. This setup would be useful when we create our pieces
later in the development so they initial position of pieces would be as it is set in this array.
For creating the board on game screen, I have set two variable board_height and board_width which
determine the width and height of the board this would be a bit smaller than the screen width and
height because must add other things like clock and player icon on side of the board, so the board
doesn’t take up the whole screen. These are set to be a multiple of 8 so the board is symmetrical.
I have also set another variable called dimensions and set it to be 8 as a chess board contains 8 rows
and 8 columns. To ensure that the squares made on the board are in right proportions in terms of board
I have also set another variable called Squaresize. This is done by dividing the board’s height by the
number of dimensions.
Now in the main game file I have created a function called drawBoard this is responsible for drawing the
actual board on the gameDisplay. To squares have alternating colours I have created a variable called
colors which uses the pygame module Color and lets me choose any colour from python colour palette. I
have chosen saddle brown and sandy brown for my squares as these are high contrast colours also, they
can be easily seen by the people who suffer from colour blindness. In addition to it adds a classy look to
the game. Then to create the board a nested loop is applied which goes through the rows first and then
columns these leads to alternating squares being drawn on screen when we call the pygame’s draw
module to draw rectangles relative to rows and columns.
Page 52 of 145
Then we would call this function in the actual gameloop and ensure that it draws the chess board. Now I
am going to evaluate this to see if it works.
Page 53 of 145
Test
Testing
number Description
2
Checking if a chess
board of proportional
squares of alternating
colours is built.
Expected Outcome
Justification
Actual Outcome
A chess board of 8 columns
and 8 rows of is made and
alternating squares should
have opposite colours.
To check if the
board is built
correctly before
pieces are added
on.
Unsuccessful test as
the bottom the
colours should be
other way around.
Actions
Required
Replace the
order the colours
are called.
Now I have replaced the order in which the colours were mentioned when they were defined in the
variable colors. This will reverse the order in which the colours will be displayed hence fixing the
problem which occurred earlier.
Now we will evaluate it again to see if the change is working effectively.
Page 54 of 145
Test
Testing
number Description
2(Retest) Checking if a chess
board of
proportional squares
of alternating colours
is built.
Expected Outcome
Justification
Actual Outcome
A chess board of 8 columns
and 8 rows of is made and
alternating squares should
have opposite colours.
To check if the
board is built
correctly before
pieces are added
on.
Successful test as
now the colours are
in right order.
Actions
Required
N/A
CREATING THE PIECES-3/10/2021
As now we have successfully created the chess board the next thing, we need for the game is the pieces.
To graphically represent pieces, I have downloaded their images from openart.org and stored them in a
file called Pieces which exists in the game’s project folder. I have renamed them but using a notation
such that the first letter would be either ‘b’ or ‘w.’ Here ‘b’ would indicate black pieces while ‘w’ will
indicate white pieces this is then followed by the name of the piece. The purpose of this notation is
when these images are loaded in the actual program they are called easily.
Now to load these I have made function called loadImages. I have created a variable called pieces which
contains the list of pieces name. Then a loop is applied which and as the loop iterates the images are
added to the dictionary called IMAGES and these images are loaded by the pygame module image. We
also passed down the SquareSize to this loading function, so each piece takes a complete square on the
board.
I have imported the GameDesign python file which I mentioned earlier during the development of the
chess board. This contain the state of the
board so the pieces will take the position on
the board as defined in this 2d array every
time the game is started. The pieces are
indicated in the same notation as they were
stored in the Pieces file. The “- -” represents
a position on the board which is vacant. This setup is like how an actual chess board with pieces would
look like before the start of a game. This purpose of importing this is to draw the game screen when
gameloop is called.
Page 55 of 145
Now I have created a function called drawPieces which would draw the pieces on the board. For this a
nested loop is applied each iterating 8 times which is equivalent to the number of the dimensions of the
board. An if statement is also applied to check if the square is not empty the image relative to it would
be loaded on the gameDisplay on the corresponding row and column. This function also contains the
SquareSize variable to ensure that each piece occupies a whole square.
I have created a variable called gameScreen which would inherit the properties of class GameCondition.
This is called in the gameloop and the purpose of this is to when the gameloop function is called it would
set out the board and pieces as they are supposed they are supposed to at the start of the game. Also,
we have called the function loadImages so the images of sprites in this case which are chess pieces are
loaded once so memory is not wasted.
As when the game starts the board and pieces should load together so I created another function called
drawGameState which contains the two functions we discussed earlier (drawBoard and drawPieces).
So, when this function is called in gameloop the board and pieces would be ready.
Page 56 of 145
Now we will call the drawGameState function in the gameloop and this would make our game screen.
Now we would run a test to see if the pieces are loaded at the squares on which they are intended and
are occupying the whole squares.
Page 57 of 145
Test
Test description
number
Checking if the pieces
3
are loaded on the
board in the right
positions.
Expected outcome
Justification
Actual outcome
The pieces should be
loaded on the board
as they would
appear in real before
the start of a game.
And they should also
occupy a hole
square.
The pieces
should be in
right order
before we
progress and
try to move
them.
Successful test.
The pieces do load
in right order, and
each occupies a
whole square.
Actions
Required
N/A
MOVING THE PIECES-10/11/2021
As now we have successfully created the pieces, now the next step is to allow these pieces to move
them around the board. For this I have created a function in the GameDesign file. This function takes
the move parameter which consists of the column value and row value of the square on the board
where we intend it to move to. It first checks if the position to be moved to is occupied or not.
If unoccupied it moves the piece else, it would check for some other conditions which would be
mentioned later in the development.
Also, in the GameDesign file we have created a class called Move. This contains the dictionary called
ranksToRows and filesToCols which contains a list of what positions on board they correspond to.
It also refers to a function which takes parameters relevant to the current position of the piece and the
position we want the piece to move to. These parameters are then passed to the function mentioned
above makeMove. The pieceMoved indicates to the position of the board where the piece must be
moved to.
Page 58 of 145
For the piece to be moved it must be selected first. For this a condition has been implemented which
checks if the mouse button has been pressed. Location variable gets the position on the screen where
the mouse has been clicked. I have used get_pos() function from the mouse module of the pygame.
Then the position retrieved is divided into two vectors as columns and rows, respectively. These both
together refer to a square on the board. Then this is passed on to the SelectedSquare and accounted to
playerClicks which keep track of clicks made for moving pieces. So now a piece has been selected. Then
a second click is made to indicate the square position to which we intend the piece to move to. We
repeat the same process again but this time we update the SelectedSquare to this new square and
append this to the PlayerClicks. Now we retrieve the number of clicks made by len(playerClicks). If it
equals two, then we call the Move class from GameDesign and pass on the parameters to it. Then we
call makeMove function to move the piece on the gameScreen.
Now a test would be conducted to check if the code works without any crashes.
Test
number
Test description
Expected outcome
Justification
Actual outcome
4
Checking if the
pieces can move
on different
squares on
board and
occupy the
whole square
Checking that
one player can
only have one
turn before the
other player gets
their turn.
When a piece is
selected by clicking
it should be moved
to the square
selected by the
user.
Need to ensure
that the pieces
can to different
squares before
allowing them to
eliminate a piece.
Once one player
has made a move
then they shouldn’t
be allowed to make
a move until
another player
makes a move.
This is necessary
as chess is a turnbased game, else
the game
wouldn’t run
properly
Successful test, as
when a piece is
selected and then
a square selected
to move it to, the
change is updated
on the screen.
Unsuccessful test,
As after the
player has made a
move, they can
still move their
piece before
another player
makes a move.
(Video2)
5
Actions
Required
N/A
Need to set a
turn-based
system.
(See test
number 10,
page 64).
Page 59 of 145
The following image shows the state of the board after a few pieces have been moved.
Page 60 of 145
ELIMINATING PIECES-17/11/2021
As now the pieces can move on the board, they should be allowed to take other pieces as well.
For this in the Move class I added a pieceCaptured function. This checks if the column and row a piece
would end at is occupied by another piece or not. If a piece exists, then that piece would be eliminated.
The following image shows the state of the board
before the piece is about to be moved to take
another piece.
This image shows the state of the board after a white pawn is
moved to square which was occupied by the black queen.
Page 61 of 145
Test
number
Expected
outcome
Check
if
a
piece
When a piece is
6
(Video3) can eliminate an moved to a
opponent’s
position which is
piece.
already occupied
by an opponent’s
piece that piece
should disappear
from screen.
Checking
if
A player
7
piece belongs to shouldn’t be
same player
allowed to
can’t be
eliminate its own
eliminated.
piece.
8
Test description
Checking if
pieces can be
eliminated by
only valid
moves.
An elimination
can only take
place by a set of
valid moves.
Justification
Actual outcome
Actions Required
For the game to
proceed it is
necessary pieces
are allowed to
eliminate
opponent’s piece.
Successful test, as
when a piece is
moved to a
position already
occupied by
another piece,
the other piece is
eliminated.
Unsuccessful test,
as player was
allowed to
eliminate its own
piece.
N/A
This is necessary
as it isn’t possible
for a player in an
actual game of
chess to eliminate
their own piece.
For a fair game of
chess to take
place it is
mandatory that
pieces can move
and eliminate in a
valid manner
corresponding to
their rank or type.
Unsuccessful test,
as player was
available to
eliminate another
piece by making a
move which was
not valid
according to the
rules of chess.
Pieces of
different colours
should be flagged
as enemy pieces
and those are the
only pieces a
player can take.
(See testing for
Generating valid
moves, page 92)
A validation
function for each
piece type of is
required which
will allow only
valid moves.
(See testing for
Generating valid
moves, page 92)
MOVING AND ELIMINATION TESTING
Test Type
Test Video
No. No.
Link
Status
Main
Menu
1
1
https://youtu.be/reLdmDXS458
Passed
Move
4
2
https://youtu.be/s0wDtLYe2kI
Passed
Elimination
6
3
https://youtu.be/DKkiycWY284
Passed
Page 62 of 145
UNDO MOVES-25/11/2021
As players can accidently move the pieces to allow them undoing that I have developed a function
called undoMove in the GameCondition class of the GameDesign. The function first checks if any move
made yet or not. This is done by checking if the length of the moveLog is not zero. If a move made is
made the last move is removed from the log by the pop() function. As this done, on the board the piece
is returned to its previous position before the move was made. In case an elimination was made it
retrieves the end position of the eliminated piece and then that piece is also spawned back to that
position. Finally, to make sure that when a move is taken back the turn goes back to player which made
the last player, I set WhiteToMove equal to its opposite. This means if initially it was white’s turn to
move before the black took the move back the turn should go back to black so an alternative move can
be made by black.
To implement this in the main game I have decided to call it when “z” key is pressed down on the
keyboard. The z key is chosen as normally we use “ctrl+z” to undo a thing. So first it checks if a key is
pressed down during the game. If a key is pressed, then it checks whether the pressed key is “z” or not.
If it is, then function undoMove is called on the gameScreen.
The image below shows the state of the board before the white pawn is about to be moved diagonally
right to eliminate a black pawn.
Page 63 of 145
This image below shows the state of the board after the white pawn has eliminated the black pawn. As
black pawn was eliminated it disappears from the board.
The image below shows the state of the board after the “z” key is pressed on the keyboard to undo the
last move. The board has restored its state before the move was made as the piece which was moved
has returned to its previous position also the piece which was eliminated has also spawned back to its
position before the move was made.
Page 64 of 145
Test
number
Test description
Checking if a
(Video4) move can be
undone by
pressing the “z”
key.
9
10
Checking that
after a player
undoes a move
its still their turn
to make an
alternative move.
Expected outcome
Justification
Actual outcome
If the “z” key is
pressed after making
a move the move
should be undone
and the board
should restore its
state which it had
before the move
was made.
If moves made
accidently stays
then the player
would be
disadvantaged.
When a move has
been undone the
last player, who
made a move before
the undo function
was called they get
another turn to
make an alternative
move.
As a move is
undone the
player should get
another turn as
when a move is
undone the game
would be in same
state as if the
player didn’t
make a move
Successful test, as
when “z” key was
pressed after a move
was made the board
restored its original
state with moved
piece back to its
previous position
and eliminated piece
spawned back.
Successful test, as
when a move is
undone the player
gets another turn to
make an alternative
move.
Actions
Required
N/A
N/A
STAKEHOLDERS FEEDBACK
As at this point a good proportion of core functionality has been developed therefore, I have decided to
get feedback from my stakeholders. So, I know what they think of current features, does they work as
they asked. Also, any changes they want to be implemented before further development.
Questions
Sayem
Ali
Conclusion
What are your
thoughts about the
main menu screen?
The buttons being
highlighted when cursor
on them makes
interacting quite easy.
I think the game screen
looks amazing and gives
a good gaming
experience.
I think after selecting if
a player keeps cursor
on another square, it
should be highlighted.
I think that this has
been implemented in
the most perfect way
possible.
The background image
gives a very cool vibe to
the menu screen.
The main menu screen
will stay like this as
both stakeholders
satisfied.
In second prototype of
game screen player
icons would be added
at the bottom.
The highlight feature
would be added in the
later development.
How do you find the
game screen?
Are you happy with
how pieces move on
the screen?
What are your views
on the implementation
of undo feature?
Everything is great but I
think player icons
should be added
indicating player’s turn.
The pieces are easy to
move but I agree the
highlight feature can
improve it further.
The idea of “z” key for
undo is great as it is
easy to use.
The undo feature would
stay unchanged in
future development.
Page 65 of 145
GENERATING VALID MOVES-02/12/2021
As now the pieces can move and eliminate it is necessary that they can only move and eliminate by the
movements which are valid with accordance to chess rules. For this I have made two functions called
getValidMoves and getAllPossibeMoves. The getValidMoves takes account of all moves considering
checkmate which would be handy when we create the logic for checkmate. The getAllPossibleMoves
just returns all the possible moves a piece can make without considering the checkmate. The turn
system is also validated here. It does this by inspecting the first letter of the piece name. As when we
named the pieces earlier the first letter determines colour of piece. If the first letter is “w” this indicates
a white piece while if its “b” then the piece is black. Then to determine the type of piece we check the
third letter of the piece name. “p” indicates pawn, “b” indicates a bishop, “q” indicates queen. As both
knight and king start with the same letter, I updated the name for the king piece to start with a capital k
so “K” indicates king while “k” indicates knight. After determining the type of piece, it calls each piece
type individual validation function and returns the move.
To implement this validation in the game_loop() I made a list called validMoves which applies all the
function from getValidMoves() to the gameScreen.
Page 66 of 145
Now to ensure only a valid move is made a check is made to ensure that the move requested exits in the
validMoves list.
VALIDATING PAWN MOVES
For generating valid moves for a pawn, I have created a function called getPawnMoves. This specifies all
the moves which can be made using a pawn. It first checks the colour of piece by checking if
WhiteToMove is true or not. Then it checks if the column on the next row is free or not. Also, at the
same time it checks if the pawn is in the row it is supposed to be at the start of the game. If in starting in
position, then allowing it to move max of two in the same column. If not, then it can move max of 1 row
forward in same column only if there is no piece at the position at already. For white to capture a black
piece it checks the square up to right or up to left is occupied by a black piece. For black to capture a
white piece it checks if the square down to right or down to left is occupied by a white piece. All these
checks are conducted by inspecting r and c. After all these checks are done it appends a move and
passes the new position parameter to board and implemented using the Move class.
Page 67 of 145
Image below shows the state of the board before the pawn is about to be moved to one row up in the
same column.
The image below shows the state of the board after the pawn is finally moved to position indicated in
image above so, allowing this valid move.
Page 68 of 145
This image shows the state of the board before we move a pawn from the starting position to two rows
up in the same columns.
This image shows the state of the board after we have moved the pawn to the position indicated in the
image above. This suggests we can generate this kind of valid move.
Page 69 of 145
This image shows the player attempting the blue circled black pawn to eliminate a white piece. The red
circled white pawn cannot be taken as it is not valid move, but the white pawn circled green can be
eliminated as that is a valid move.
This image shows the state of the board after black pawn was only allowed to eliminate the white pawn
on the diagonal. This suggests that validation has been successful as only valid moves result in
elimination.
Page 70 of 145
Test
number
Test description
Expected outcome
Justification
Actual outcome
10
Checking if a
pawn can move
one row up in
same column, or
two rows up in
same column if in
the starting row.
Checking if a
pawn can only
eliminate an
opponent’s piece
if its only one
forward diagonal.
The pawn should
move to one row up
in the same column
if the square is
empty, two rows up
in case the pawn is in
the starting row.
A pawn should be
allowed to eliminate
a piece if it’s only
one diagonal
forward.
It is necessary
that a piece can
only move with
accordance to
chess rules.
Successful test, as
the pawn only
moves to position
which were
validated.
A pawn can’t take
a piece directly
one row up as it
is not in
accordance with
chess rules.
N/A
Checking if both
(Video5) elimination and
moving to empty
square function
properly without
any errors.
For one move only
one of above
conditions should be
applicable the other
condition should be
ignored.
Checking if a
different pawn is
selected after
selecting one
before the
selected piece is
now updated.
If a different piece is
selected after
initially selecting
another piece, it
should override, and
selected piece
should be updated.
For a fair and
completely
functional game
to take place It is
necessary that
both don’t take
place at the same
time.
If player decides
to use another
piece the
transition should
be easy else they
won’t be able to
play smoothly.
Successful test, as
the pawn was
only able to
eliminate a piece
if it was with
accordance chess
rules.
Successful test, as
in all cases the
right condition
took priority
which avoided
any errors to take
place.
Unsuccessful test,
as when another
piece was
selected and was
intended to move
to different
position, it was
not updated on
the board.
Update the
selected
square and
player clicks
in such way
that other
pieces can
be selected
and move
efficiently.
11
12
13
Actions
Required
N/A
N/A
To update the selected square in case a valid move was not made I have modified the condition where it
checks if a valid move is made or not. If a move is made, then playerClick is update else the playerClick
would change to the selectedSquare so now that would be our selected piece. So, it can be moved.
Page 71 of 145
Test
number
Test description
Checking if a
(Retest) different pawn is
selected after
selecting one
before the
selected piece is
now updated.
13
Expected outcome
Justification
Actual outcome
If a different piece is
selected after
initially selecting
another piece, it
should override, and
selected piece
should be updated.
If player decides
to use another
piece the
transition should
be easy else, they
won’t be able to
play smoothly.
Successful test, as
when another
piece was
selected and was
intended to move
to different
position, it was
updated on the
board.
Actions
Required
N/A
VALIDATING ROOK MOVES
For generating valid moves for a pawn, I have created a function called getRookMoves. This specifies all
the moves which can be made using a rook. I have created a tuple called directions which contains all
the position a rook can move in form of x-coordinate and y-coordinate. The directions include left, right,
up, and down. Then we determine the enemyColor by checking if WhiteToMove is true or not. If true,
then black is the enemy colour else white is the enemy colour. Then a loop has been implemented in
range eight which is the furthest the piece can move to horizontally or vertically, so now these
parameters are passed on to endRow and endCol which would be the position of the piece after it is
moved. To ensure the piece stays on the board we check the endCol and endRow are between zero and
eight as the max number of rows and columns are eight. If in the given range, then these are passed
onto the variable endPiece which is a string. Then we check if the square it wants it to be moved to is
empty or not. In case empty the move is valid and would be made on the screen. We also check if the
endPiece is at such position where enemyColor is true or not. If true, then that piece would be
captured. A break statement has been called after this to ensure that the piece does not jump over an
enemy piece.
Page 72 of 145
The image below shows the state of the board before the white rook is about to be moved to its right in
the different column while staying in the same row which is valid move.
The image below shows the state of the board when the move is made which suggests valid moves
horizontally are allowed.
Page 73 of 145
The image below shows the state of the board before the black pawn tries to move horizontally left to a
square which is already occupied by own piece which is not a valid move so should not be allowed. The
green circle shows the alternative move which is moving vertically and eliminating an enemy piece
which should be allowed.
The image shows the state of the board after the move mentioned above was made. It did not allow to
eliminate an own piece but allowed it to eliminate enemy piece, it also showed that the piece was
moved vertically suggesting that validation has been implemented successfully.
Page 74 of 145
The image shows the state of the board before we try to eliminate the black pawn with the white rook.
This move should not be allowed as there is a white pawn between them and rook cannot jump over its
own piece.
The image shows that the white rook was allowed to eliminate the black pawn, even though there was a
white pawn between. This suggests that a break would be needed to stop rook jumping over its owncoloured pieces.
Page 75 of 145
Test
number
Test description
Expected outcome
Justification
Actual outcome
14
Checking if a rook
can move one
any number of
squares
horizontally or
vertically if
squares are
empty and
nothing between.
Checking if a rook
can only
eliminate an
opponent’s piece
if it is in the same
row or column as
the rook itself.
Checking if the
rook doesn’t
jump over its own
piece to occupy
an empty square
or eliminate an
enemy piece.
The rook should
only move either
horizontally in a
line or vertically, no
diagonal
movement should
be allowed as not
in accordance with
chess rules.
The rook should be
able to eliminate
an enemy’s piece if
in the same row or
column.
It is necessary that
a piece can only
move with
accordance to
chess rules.
Successful test, as
the rook only
moves to position
which were
validated.
A piece should only
be able to
eliminate an
enemy’s piece, also
the elimination can
only take place by
a valid move.
A rook can’t take a
square further
than its owncolored piece if
that piece is in its
path.
Successful test, as
the rook was only
able to eliminate
a piece if it was
with accordance
chess rules.
N/A
Unsuccessful test,
as the rook was
able to jump over
its own piece
which is not a
valid move.
A break
should be
implemented
if own piece
is in path to
stop it from
jumping
over.
15
16
If a rook tries to
jump over its own
piece the move
shouldn’t be
allowed.
Actions
Required
N/A
To resolve the error a break statement has been implemented. This ensures that the rook does not jump
over piece of the same colour. I have also added another break statement which ensures the piece does
not go off the board. This would be useful in later development when player icons would be icon on
sides so the game does not crash if a click is made off the board.
Page 76 of 145
Test
number
Test description
Checking if the
(Retest) rook doesn’t jump
over its own piece
to occupy an
empty square or
eliminate an
enemy piece.
Checking if all
17
(Video6) cases are covered
and priority is
given rightly so
they work without
any crashes.
16
Expected
outcome
If a rook tries to
jump over its own
piece the move
shouldn’t be
allowed.
Justification
Actual outcome
A rook can’t take a
square further than
its own-colored
piece if that piece
is in its path.
Successful test, as
the rook was not
allowed to jump over
its own piece so
following valid
moves.
All valid moves
should be
allowed while all
invalid moves
shouldn’t be
allowed.
For a fair game to
take place its
necessary that
piece is only able to
perform valid
moves.
Successful test, as
only valid moves
were allowed when
moving to an empty
square or eliminating
an enemy’s piece.
Actions
Required
N/A
N/A
VALIDATING BISHOP MOVES
For generating valid moves for a bishop, I have created a function called getBishopMoves. This specifies
all the moves which can be made using a bishop. I have created a tuple called directions which contains
all the position a bishop can move in form of x-coordinate and y-coordinate. The directions include
diagonal movements. Then we determine the enemyColor by checking if WhiteToMove is true or not. If
true, then black is the enemy colour else white is the enemy colour. Then a loop has been implemented
in range eight which is the furthest the piece can move diagonally, so now these parameters are passed
on to endRow and endCol which would be the position of the piece after it is moved. To ensure the
piece stays on the board we check the endCol and endRow are between zero and eight as the max
number of
rows and
columns
are eight. If
in the given
range, then
these are
passed
onto the
variable
endPiece
which is a
string. Then
we check if
the square
it wants it to be moved to is empty or not. In case empty the move is valid and would be made on the
screen. A break statement has been called after this to ensure that the piece does not jump over its
own-coloured piece. We also check if the endPiece is at such position where enemyColor is true or not.
If true, then that piece would be captured.
Page 77 of 145
The image shows the state of before the player tries to move the white bishop to several positions. Out
of the three circles highlighted only the green one should be allowed as red is occupied by own player so
not valid while yellow one cannot be made as own piece is in the path.
The image shows the state of the board all three moves were tried. As it only moved to the empty
square with none of own piece in path suggests that validation for moving to empty square is successful.
Page 78 of 145
This image shows the state of the board before the player tries to move the black bishop. The square
marked with red and yellow circle should not be allowed as bishop cannot move just horizontally or
vertically. The square circled green should be allowed as it is on a diagonal and the piece belongs to
enemy.
This image shows the state of the board after all moves mentioned above are tried. The one circled
yellow and red weren’t allowed while the one circled green was allowed suggesting that only valid
moves were allowed.
Page 79 of 145
The image shows the state of the board before the player tries to eliminate the black pawn circled red
with the white bishop. This should not be allowed as there is already a black pawn in the path.
The image shows that the white bishop was able to eliminate the black pawn. This suggests validation
hasn’t been implemented successfully as the piece can jump over enemy’s piece.
Page 80 of 145
Test
number
Test description
Expected outcome
Justification
Actual outcome
18
Checking if a
bishop can move
one any number
of squares
diagonally if
squares are
empty and
nothing between.
It is necessary that
a piece can only
move with
accordance to
chess rules.
Successful test, as
the bishop only
moves to position
which were
validated.
19
Checking if a
bishop can only
eliminate an
opponent’s piece
if it is in the
diagonal path of
the bishop.
Checking if the
rook doesn’t
jump over its
enemy’s piece to
eliminate another
enemy piece.
The bishop should
only move
diagonally, only
horizontal, or
vertical movement
should not be
allowed as not in
accordance with
chess rules.
The bishop should
be able to
eliminate an
enemy’s piece if it
is in the diagonal
path.
A piece should only
be able to
eliminate an
enemy’s piece, also
the elimination can
only take place by
a valid move.
A bishop can’t take
a square further
than its owncolored piece if
another enemy
piece is in its path.
Successful test, as
the bishop was
only able to
eliminate a piece
if it was with
accordance chess
rules.
Unsuccessful test,
as the bishop was
able to jump over
its enemy’s piece
which is not a
valid move.
20
If a bishop tries to
jump over an
enemy piece to
eliminate another
enemy’s piece the
move shouldn’t be
allowed.
Actions
Required
N/A
N/A
A break
should be
implemented
if an enemy
piece is in
path to stop
it from
jumping
over.
To resolve the problem above a break statement has been implemented. This prevents the bishop to
jump over an enemy piece to eliminate another piece. So now the bishop would not be able to jump
over another enemy piece.
Page 81 of 145
Test
number
Test description
20
Checking if the
bishop doesn’t
jump over its
enemy’s piece to
eliminate another
enemy piece.
(Retest)
Checking if all
(Video7) cases are covered
and priority is
given rightly so
they work without
any crashes.
21
Expected
outcome
If a bishop tries to
jump over an
enemy piece to
eliminate another
enemy’s piece
the move
shouldn’t be
allowed.
All valid moves
should be
allowed while all
invalid moves
shouldn’t be
allowed.
Justification
Actual outcome
A piece should only
be able to
eliminate an
enemy’s piece, also
the elimination can
only take place by a
valid move.
Successful test, as
the bishop was not
allowed to jump over
an enemy piece so
following valid
moves.
For a fair game to
take place its
necessary that
piece is only able to
perform valid
moves.
Successful test, as
only valid moves
were allowed when
moving to an empty
square or eliminating
an enemy’s piece.
Actions
Required
N/A
N/A
VALIDATING QUEEN MOVES
As the queen can move like either a rook or a bishop so, I have decided to just call the getBishopMoves
and getRookMoves instead of rewriting everything which was done for the bishop and the rook. These
would save time as these are already assessed and maintained individually.
The image below shows the state of the board before the white queen is about to be moved. The green
circle refers the positions the queen can move to while the positions circled red are the positions that
should not be allowed.
Page 82 of 145
The image below shows the state of the board after the white queen is moved to its left diagonal
suggesting that the bishop moves for queen are implemented successfully.
The image below shows the state of the board after the red circled moves were tried but none took
place suggesting that own pieces cannot be implemented, and invalid moves cannot be made. Moving it
to one row up in the same column was a valid move and was allowed. This suggests the rook moves for
queen have been implemented successfully.
Page 83 of 145
The image below shows the state of the board before the black queen is to be moved. If the queen is
moved to the position where the pawn circled green is located the elimination should take place as the
move is valid. The pawn circled red should not be allowed to eliminate as there is an own piece in
between and queen can’t jump its own piece.
The image below shows the state of the board after both moves were tried. Only the valid one was
allowed suggesting that elimination is only possible via set of legal moves also confirms that the queen
can’t jump over its own piece.
Page 84 of 145
Test
number
Test description
22
Checking if a queen
can only move like
a bishop or a rook
but not adding
both two added in
one turn.
23
The bishop should
only move diagonally,
only horizontal, or
vertical movement
should not be allowed
as not in accordance
with chess rules.
Checking if a queen The queen should be
can only eliminate able to eliminate an
an opponent’s
enemy’s piece only if
piece if it is a valid the move is valid.
move.
Checking if the
(Video8) queen doesn’t
jump over its own
piece or an
enemy’s piece. And
still can move and
eliminate via valid
moves.
24
Expected outcome
If a queen tries to
jump over an enemy
piece or its own piece
the move shouldn’t be
allowed.
Justification
Actual outcome
It is necessary that
a piece can only
move with
accordance to
chess rules.
Successful test,
as the queen
only moves to
position which
were validated.
A piece should only
be able to
eliminate an
enemy’s piece, also
the elimination can
only take place by
a valid move.
A queen can’t take
a square further
than its owncolored piece.
Successful test,
as the queen was
only able to
eliminate a piece
if it was with
accordance
chess rules.
Successful test,
as the queen
could not jump
over enemy’s
piece or its own
piece which is
not a valid move.
Actions
Required
N/A
N/A
N/A
Page 85 of 145
VALIDATING KNIGHT MOVES
For generating valid moves for a knight, I have created a function called getKnightMoves. This specifies
all the moves which can be made using a knight. I have created a tuple called directions which contains
all the position a knight can move in form of x-coordinate and y-coordinate. The directions include 2 in
one direction in one in the other. Then we determine the enemyColor by checking if WhiteToMove is
true or not. If true, then black is the enemy colour else white is the enemy colour. Then a loop has been
implemented in range eight which is the furthest the piece can move, parameters are passed on to
endRow and endCol which would be the position of the piece after it is moved. I have not implemented
a break function for jumping over as the knight can jump over both its enemy piece and own piece.
The image below shows the state of the board before the white knight circled blue is to be moved. The
green circle refers to the position the moves which are valid while the red circled positions to the moves
which are invalid. Only valid moves should be allowed.
Page 86 of 145
The image shows the state of the board after the valid move was made suggesting valid moves are
allowed.
The image shows the state of the board after the invalid moves were tried. It didn’t allow to eliminate
own piece but allowed an enemy piece to be eliminated by an invalid move. This suggests the validation
hasn’t been implemented successfully.
Page 87 of 145
Test
number
Test description
25
Checking if a
knight can only
make valid
moves. Which
are one in one
direction and
two in the other
direction.
Checking if a
knight can only
eliminate an
opponent’s piece
by a set of valid
moves.
26
Expected
outcome
The knight should
only move one
square in one
direction and two
in the other
direction.
Justification
Actual outcome
It is necessary that
a piece can only
move with
accordance to
chess rules.
Unsuccessful
test, as the
knight was able
to make moves
which were not
valid.
The knight should
be able to
eliminate an
enemy’s piece
only if the move is
valid.
A piece should
only be able to
eliminate an
enemy’s piece,
also the
elimination can
only take place by
a valid move.
Unsuccessful
test, as the
knight was able
to eliminate a
piece even
though it was not
in accordance
with chess rules.
Actions
Required
The logic for
getKnightMoves
must be
changed so only
valid moves are
allowed.
The logic for
getKnightMoves
must be
updated so
elimination is
only possible via
valid moves.
So, to resolve the errors I have updated the logic for getKnightMoves. I have discarded the enemyColor
variable and replaced with ownColor variable which checks whether the piece is an ally of the piece
selected move. The loop is changed now, and it goes through the possible moves in the tuple directions.
To move a piece, it is checked does the valid move generated would result the piece to a square where
ownColor is false meaning the square is not occupied by own piece. If ownColor is false, then the move
is made else the user is expected to make another move.
Test
number
Test description
Checking if a
(Retest) knight can only
(Video9) make valid
moves. Which are
one in one
direction and two
in the other
direction.
25
Expected outcome
Justification
Actual outcome
The knight should
only move one
square in one
direction and two
in the other
direction.
It is necessary that
a piece can only
move with
accordance to
chess rules.
Successful test, as
the knight was
able to make
moves which
were not valid.
Actions
Required
N/A
Page 88 of 145
Checking if a
(Retest) knight can only
(Video9) eliminate an
opponent’s piece
by a set of valid
moves.
26
The knight should
be able to
eliminate an
enemy’s piece only
if the move is valid.
A piece should
only be able to
eliminate an
enemy’s piece,
also the
elimination can
only take place by
a valid move.
Successful test, as
the knight was
able to eliminate
a piece even
though it was not
in accordance
with chess rules.
N/A
VALIDATING KING MOVES
For generating valid moves for a king, I have created a function called getKingMoves. This specifies all
the moves which can be made using a king. I have created a tuple called directions which contains all
the position a king can move in form of x-coordinate and y-coordinate. The directions include left, right,
up, and down. Then we determine the ownColor by checking if WhiteToMove is true or not. If true,
then white is the ally colour else black is the ally colour. So now these parameters are passed on to
endRow and endCol which would be the position of the piece after it is moved. To ensure the piece
stays on the board we check the endCol and endRow are between zero and eight as the max number of
rows and columns are eight. If in the given range, then these are passed onto the variable endPiece
which is a string. Then we check if the square it wants it to be moved to is empty or not. In case empty
the move is valid and would be made on the screen. We also check if the endPiece is at such position
where enemyColor is true or not. If true, then that piece would be captured. Two break statements
have been called after this to ensure that the piece does not jump over an enemy piece or an ally piece.
Page 89 of 145
The image below shows the state of the before the white king is to be moved. The green circled position
refers to valid moves while ones circled red refers to invalid moves. The valid moves should be allowed
while invalid moves should be disallowed.
The image below shows the state of the board after the white king was moved. The move was made to a
green circled position so indicating a valid move was allowed.
Page 90 of 145
The image below shows the state of the board when another valid move was carried. In this case the white
king eliminated a black pawn which was in the same row in next column. So, king can successfully
eliminate an enemy piece.
The image below shows the state of the after two moves were tried. We first tried the invalid move of
eliminating an ally piece. This was not allowed so referring that elimination logic has been implemented
successfully. The other move we tried was a valid move so was allowed. This suggests that king moves
have been implemented successfully.
Page 91 of 145
Test
number
Test description
Expected
outcome
Checking
if
a
king
The king should
27
be to make valid
(Video10) can only make
valid moves and
moves and
eliminate an
should only be
opponent’s piece if able to
it is a valid move.
eliminate an
enemy’s piece
only if the move
is valid.
Checking if the
If a king tries to
28
king
doesn’t
jump
jump over an
(Video10)
over its own piece enemy piece or
or an enemy’s
its own piece
piece. And still can the move
move and
shouldn’t be
eliminate via valid allowed.
moves.
Checking if before If a move can
29
moving a king,
put the king in
moves that would checkmate the
put it in
move should be
checkmate are
disallowed.
disabled.
Justification
Actual outcome
A piece should only
move with
accordance with
chess rules and be
able to eliminate an
enemy’s piece, also
the elimination can
only take place by a
valid move.
A king can’t take a
square further than
its own-colored
piece or an enemy’s
piece.
Successful test,
as the king was
only able to
eliminate a
piece if it was
with accordance
chess rules.
It’s in an invalid
move to make such a
move with king that
will put it in check.
Successful test,
as the king
could not jump
over enemy’s
piece or its own
piece which is
not a valid
move.
Unsuccessful
test, as the king
was able to
move on a
position which
would put in in
checkmate.
Actions
Required
N/A
N/A
Logic for
checkmate
should be
created in
such way
that it
modifies
possible
moves
considering
checkmate.
Page 92 of 145
VALID MOVE GENERATION TESTING
Piece
Type
Test Video
No. No.
Link
Status
Pawn
12
5
https://youtu.be/rurtm0kE4Rg
Passed
Rook
17
6
https://youtu.be/C9ZLRsXGOv0
Passed
Bishop
21
7
https://youtu.be/MvKwAzUjsTM
Passed
Queen
24
8
https://youtu.be/xFGIh4BMoS8
Passed
Knight
25,26
9
https://youtu.be/W2CqCtqLmIY
Passed
King
28,27
10
https://youtu.be/5tc88as0-c0
Passed
CHECKMATE AND STALEMATE-17/12/2021
To create the logic for checkmate the first step is to check whether the king is under attack or not. For
this I have created a function called squareUnderAttack this checks whether a piece is under attack or
not. This is achieved by generating all possible moves for the opponent which is in the list
opponentMoves. To check piece is being attacked we check whether the move is result in such position
that an opponent piece can end up on the same square by a valid move.
The initial position of both kings is recorded as tuples. This would be required to be updated throughout
the game to determine the piece is in checkmate or not. Also, we have initialised checkmate and
stalemate to be not true. The game would end as one of these changes during the game.
Page 93 of 145
To update the kings’ location a condition has been added to the makeMove method. It checks whether
the piece is moved is a king piece or not. If a king piece is moved, then the relevant tuple is updated.
To then check if the current player is under checkmate or not another method inCheckmate is created.
This is done by checking if WhiteToMove is true or not. If white to move, then then white kings’ is under
checkmate else the black king is under checkmate this is achieved by passing squareUnderAttack
function to relevant king piece.
To implement this, I have modified the getValidMoves method which generates all the moves
considering checkmate. So now it first generates all the possible moves and then makes the move. Then
it checks whether then generates all moves for opponent. If an opponents’ move will result in your king
being under attack. If king is under attack, then that move is not valid and should not be allowed. If
inCheckmate is true at any point, then it removes all moves that will result in game to stay in checkmate
position. If no more moves can be generated, then it checks whether the inCheckmate is true or not. If
inCheckmate is true, then checkMate is true so game should now end via checkmate. Otherwise
stallemate is true and game should now end via stalemate.
Page 94 of 145
Now in the main I have added a condition in the gameloop. This checks if the checkMate is true then
fill the gameDisplay black. Then it created buttons to navigate to main menu, to play the game again or
just to quit the game. It then checks which player was supposed to make a turn when checkMate came
out to be true. If it was whites’ turn to move, then black wins otherwise white wins. This is achieved by
checking if WhiteToMove is true or not. Then it draws the game over text and the text for either player
winning the game.
Page 95 of 145
The image below is before the black queen is to be moved the diagonal square circled green. This
position is also known as a fool’s mate. This is the fastest way to checkmate. After the move is made the
game should end and game over screen should be displayed.
The image shows the state of the board after the move was made. The game didn’t end also white king
was allowed to make a move which would keep it in checkmate. This suggests the logic for checkmate
hasn’t been implemented correctly.
Page 96 of 145
Test
number
Test description
30
Checking if the king
is in checkmate
position then
moves that can
take game out of
checkmate are
allowed only.
31
Checking if the
game is checkmate
position and no
legal moves can be
made then win
should be awarded
to player who
attacked others’
players’ king.
Checking if no legal
moves can be
made then
checkmate is
flagged and the
game over screen is
loaded.
32
Expected
outcome
Any move that
keeps the game
in checkmate
position should
be disallowed.
If the game is
checkmate and
no legal moves
can be made
then the player
who attacked
others’ king
should be
awarded a win.
When the
checkmate is
flagged with no
legal moves
remaining then
game over
screen should
load.
Justification
Actual outcome
Actions
Required
It is illegal in chess
Unsuccessful
The
to make a move that test, as when in getValidMoves
will result in
checkmate a
function should
checkmate to stay.
move was
be modified that
So not in
allowed that did these moves
accordance with
not took game
should be
chess rules.
out of
disabled.
checkmate.
If no legal moves
Unsuccessful
The
can be made and
test, as when
getValidMoves
game is in
no legal moves
function did not
checkmate position could be made
considered that
then win should be
while being in
no legal moves
awarded as that is
checkmate the
could be made
what would happen win was not
so needs
in a real game of
awarded.
amended.
chess.
As checkmate is
Unsuccessful
The
flagged and no legal test, as
getValidMoves
moves can be made checkmate was function did not
the players should
not flagged so
flagged
be notified that
the game over
checkmate so
game is over and
screen did not
needs some
the winner should
load.
fixing.
be announced.
As all the three errors were related to with the getValidMoves function so I decided to modify it. The
error occurred as when we were iterating through the list when a move was removed then when it was
checking for again for moves to be removed it indexed the list in such way that all the indexes shifted
to the left, so it skipped over the next index which was required to be checked. This can be resolved by
checking the listing backwards so even when items are removed the index of items to be checked is
unchanged so none of them is skipped over. The code has now been modified so the errors occurred
earlier can be resolved.
Page 97 of 145
The image below is before the black queen is to be moved the diagonal square circled green. This
position is also known as a fool’s mate. This is the fastest way to checkmate. After the move is made the
game should end and game over screen should be displayed.
The image below is after the move was made and game ended via checkmate. As the game ended the
game over text was displayed along with winning text and buttons for the player to navigate.
Page 98 of 145
Test
number
Test description
30
Checking if the king
is in checkmate
position then moves
that can take game
out of checkmate
are allowed only.
(Retest)
Checking if the
game is checkmate
(Retest)
position and no
legal moves can be
made then win
should be awarded
to player who
attacked others’
players’ king.
Checking if no legal
32
moves can be made
(Retest)
(Video11) then checkmate is
flagged and the
game over screen is
loaded.
31
Expected
outcome
Any move that
keeps the game in
checkmate
position should be
disallowed.
Justification
Actual outcome
It is illegal in chess to
make a move that
will result in
checkmate to stay.
So not in accordance
with chess rules.
If the game is
checkmate and no
legal moves can
be made then the
player who
attacked others’
king should be
awarded a win.
If no legal moves can
be made and game
is in checkmate
position then win
should be awarded
as that is what
would happen in a
real game of chess.
Successful test,
as when in
checkmate only
move that was
allowed was the
one that took
game out of
checkmate.
Successful test,
as when no legal
moves could be
made while
being in
checkmate the
win was
awarded.
When the
checkmate is
flagged with no
legal moves
remaining then
game over screen
should load.
As checkmate is
flagged and no legal
moves can be made
the players should
be notified that
game is over and the
winner should be
announced.
Successful test,
as checkmate
was flagged and
the game over
screen loaded.
Actions
Required
N/A
N/A
N/A
PROMOTION-03/01/2022
Promotion of pawn to other higher rank pieces is one of the essential features. To achieve this, I have
added a variable called PawnPromotion in the Move class of GameDesign. Initially it is set as false.
When a pawn is moved it check whether it has reached the further most position or not if it has reached
the farthest position which is the row where the enemy king is at the start of the game then
PawnPromotion is flagged as true.
To implement it in the gameloop I have added a condition in that checks that after a valid move is made
whether PawnPromotion is true or not because of that move. If true, then player would be able to
choose which kind of piece they want their pawn to be promoted to.
Page 99 of 145
To let the player, choose the kind of piece they want the piece to be promoted to, I have made a
variable called choice which lets the player input their choice via keyboard in the visual studio code
terminal. After the input has been entered by the player it is checked whether it is the name of one of
the pieces that it can been promoted to. Then the colour of the piece to be promoted to it determined
by retrieving the first later of the piece moved then we add the relevant piece notation as it was in the
dictionary which was made at the start of the development. So now the pawn will be replaced by the
chosen piece on that position on the board.
Validation
Implementing the pawn promotion by this method requires the player to navigate back to the visual
studio code terminal to input their choice. Also, it requires the player to spell the piece type correctly.
Only four inputs are allowed which are (queen, knight, bishop, and rook). Anything apart from this
cannot be executed also the user will not be asked to enter their choice again until a valid choice is
made. The player is also expected to enter the input in lowercase alphabets. After the input, the
player must press enter and navigate back to the pygame window on which the game was running. If
the player fails to do any of this, then the game would not proceed further.
Page 100 of 145
The image below shows the state of the board before the white pawn will eliminate the black knight and
the user would be presented with a promotion choice.
The below shows the pygame window when the player clicked on the board after the promotion choice
appeared in the visual studio code terminal. The pygame window went unresponsive till the time player
entered a valid input in the terminal.
The image below shows that player has been asked for a promotion choice.
The player entered the queen as their input so the pawn can be promoted to a queen piece.
Page 101 of 145
The image below shows the state of the board after the player returns to pygame window after entering
“queen” as their input. As we can see the pawn has been replaced by a queen piece which means
promotion has been successful.
Test
number
Test description
33
Checking when
promotion is
flagged and a
relevant choice in
entered, is the
piece promoted
successfully or
not.
Checking that
when promotion
choice is offered
the game window
doesn’t crash.
34
Expected
outcome
When a pawn has
reached farthest
position,
promotion should
be flagged, and
piece should be
promoted to the
players’ choice.
When the player
navigates to make
a promotion
choice the process
should take place
without any
crashes.
Justification
Actual outcome
When promotion
is flagged the
player should have
the option to
choose and that
choice should be
updated on the
board.
If crashes occur
during the game it
will ruin the game
experience and
game may not be
able to be
completely
playable.
Successful test,
as when in
promotion was
flagged and
relevant input
entered it was
promoted to the
players’ choice.
Unsuccessful
test, as when
promotion choice
was offered the
pygame window
stopped
responding and
crashed.
Actions
Required
N/A
The promotion
choice should be
offered in such
way that the
player does not
have to leave
the game
window.
To resolve this issue, I have decided to make selection boxes which will present the player with options
which can be locked by clicking. This will be helpful as it is free of the validations of the previous input
system as now, they do not need to type and navigate between windows. For this purpose, I have
imported tkinter which is highly effective GUI toolkit for python.
Page 102 of 145
Then the following code was produced to create a selection box with title “Choices” that present the
player with 4 choices named “Queen”, “Knight”, “Bishop” and “Rook”. These choices are the name of
pieces the pawn can be promoted to. The player can secure their choice by first clicking at their choice
and then closing the choice box.
This choice is the checked with pieces name and the piece is changed to the choice the same way as it
was done with the previous system.
The image below shows the state of the board before the white pawn will eliminate the black knight and
the user would be presented with a promotion choice.
Page 103 of 145
The image below shows the selection box which appears when promotion is flagged. The player chooses
Queen from the selection box this is confirmed by Queen being visible on the title of the box.
The image below shows the state of the board after the player closes the selection box after choosing
Queen option. As we can see the pawn has been replaced by a queen piece which means promotion has
been successful.
Test
number
Test description
Checking that
when promotion
(Retest)
(Video12) choice is offered
the game
window doesn’t
crash.
34
Expected
outcome
When the player
navigates to
make a
promotion choice
the process
should take place
without any
crashes.
Justification
Actual outcome
If crashes occur
during the game it
will ruin the game
experience and
game may not be
able to be
completely
playable.
Successful test,
as when
promotion
choice was
offered the
promotion took
place without
any crashes.
Actions
Required
N/A
Page 104 of 145
STAKEHOLDERS FEEDBACK
As at this point a good proportion of core functionality has been developed and most of the essential
features are met therefore, I have decided to get feedback from my stakeholders. So, I know what they
think of current features, are they satisfied with the product so far. Also, any changes they want to be
implemented before further development.
Questions
Sayem
Ali
Conclusion
What are your
thoughts about the
validation of pieces?
The validation of pieces
would be immensely
helpful as illegal moves
would be disallowed
automatically.
The validation of pieces
would further enhance
the experience when
the guiding pointer is
added to highlight valid
moves.
Are you satisfied with
how checkmate works?
I am satisfied with how
checkmate works and
look forward to
addition of fifty move
rule.
I am happy with how it
is being implemented; I
feel some sort of sound
alert should be added
to notify the player.
Are you happy with
how promotion choice
is offered?
The choice box is easy
to use and removes the
hassle of navigating
through windows to
promote the piece.
The buttons and text
were fine but maybe
the background does
not suit the theme.
Although this is simple
and easy to use, I would
prefer a graphical
selection box with
images of the pieces.
The validation logic has
been implemented
successfully; the guiding
pointer would be added
in further development
to make it more
obvious for the player.
The feature has been
implemented
successfully; sound
features would be
added during future
development.
The choice box will be
upgraded so that player
can click on the image
of piece to promote it.
How do you find the
game over screen?
The font style was very
cool, and the idea of
buttons improves the
navigation.
Overall, the format
would remain the same
only the background
needs changing.
GUIDING POINTER- 02/02/2022
As now most of the essential features are met, I am moving on to development of desirable features.
Guiding pointer is one of the desirable features which would highlight the valid moves for a piece when
a piece is selected. To achieve this, I have made a function called GuidingPointer. I have passed the
parameters gameDisplay, gameScreen, SelectedSquare and validMoves. The gameDisplay is there to
reference the game display while gameScreen is to reference the board and piece. The SelectedSquare
refers to the square on the board while validMoves would be required to know which squares are to be
highlighted. First, we check if the square we have selected is not empty as for valid moves to be
highlighted for a piece, a piece is required to be there in the first place. If there is a piece, then row and
column is passed on to the selected square. Then another condition is implemented to check if the piece
selected belongs to the player whose turn is it to make a move. So, if WhiteToMove is true that means
its whites’ turn and only valid moves for white pieces should be highlighted else if not true then its
blacks’ turn and only valid moves for black pieces should be highlighted. So now to highlight the square I
Page 105 of 145
have created a variable called s which refers to the surface to be highlighted and I have passed on the
SelectedSquare parameters to it. Then I have used the fill function to fill the surface of selected square
with the colour dark blue. Then to highlight the squares it can move to a loop has been implemented
which goes through moves from the validMoves list. So, to decide which piece to highlight a condition
has been implemented which checks whether the starting row and column of the move is same as the
row and column of the selected square. If same, then it highlights all the valid moves on the board for
that piece. The valid moves would be highlighted as green.
Now to use it in the game I have called it in the function drawGameState which is responsible for
drawing the board and pieces.
The image below shows the state of the board after the highlight function was conducted on a queen
piece. It has highlighted all the valid moves so suggesting guiding pointer is working.
Page 106 of 145
Test
number
Test description
35
Checking that
guiding pointer
functions
properly when a
piece is selected.
36
Checking that
pieces and square
can still be seen
when they are
highlighted.
Expected
outcome
When a piece is
selected then all
the valid moves
should be
highlighted.
Justification
Only valid moves
should be
highlighted else it
will encourage
invalid moves to
be made.
When the piece is If the player is
selected the piece unable to see their
itself, any piece it own piece, an
can eliminate or
empty square, and
any square it can
any enemy piece
take should still be then they won’t be
visible even after
able to distinct
being highlighted. between them.
Actual outcome
Successful test,
as all the valid
moves were
highlighted
successfully.
Unsuccessful
test, as when
highlighted
unable to see
which squares
had any piece on
it.
Actions
Required
N/A
The
GuidingPointer
should be
modified so the
transparency
can be added to
it.
To fix this I have added the set_alpha which takes a value for the transparency for the entire image. I
have given it the value one hundred as with that value we can see the highlighting and the pieces and
squares on the board.
The images below show the state of the board after different pieces were selected to test the Guiding
pointer.
Page 107 of 145
Test
number
Test description
Checking that
pieces and
(Retest)
(Video13) square can still
be seen when
they are
highlighted.
36
Expected
outcome
When the piece is
selected the piece
itself, any piece it
can eliminate or
any square it can
take should still
be visible even
after being
highlighted.
Justification
Actual outcome
If the player is
unable to see
their own piece,
an empty square,
and any enemy
piece then they
won’t be able to
distinct between
them.
Successful test,
as when
highlighted the
player was able
to see distinct
between empty
squares and
pieces with
enemy on it.
Actions
Required
N/A
Page 108 of 145
SOUND EFFECTS & MUSIC- 10/02/2022
Sound effects are also part of the desirable features. To implement them into the game I have first
loaded the sounds using the Sound module from in the mixer module from the pygame library. To play
the background music I have loaded a music file called chessMusic and loaded it using the music
module. The gameOverSound would be played when the game is over, pieceSound would be played
after a move is made while the promotionSound would be played when a pawn has been successfully
promoted to a higher ranked piece.
As the background music needs to play till the game ends, I have passed on -1 to play function. This will
result in music being continuously played until the game ends. This command is called in the gameloop
so the music will start playing as soon as the player enters the gameloop.
As I want to stop the music as soon as the game ends, I have used the stop function to stop the music
playback. This command is called after the gameOver is true so this means the game has ended and now
the game over screen would be loaded.
The pieceSound should be played after a move is made so I have called it after moveMade is true.
The gameOverSound is played when the gameOver is true and the game over screen has loaded.
The promotionSound is played when the promotion choice has been made and the promoted piece is
placed on the position so moveMade is true.
Page 109 of 145
The following error appeared when the code was executed after the addition of the sound effects. The
pygame was unable to open the music file pieceSound.
Test
number
37
Test description
Expected
outcome
Checking that all
The sound effects
sounds are played should play at
at their specified
their satisfied
time in the game time in the game
and the
and background
background music music should
continues to play continue while
until the game is
gameOver isn’t
over.
true.
Justification
Actual outcome
If the sound
effects and music
doesn’t play at the
right point then
that will bring
down the overall
gaming
experience.
Unsuccessful
test, as the game
did not proceed
as pygame was
unable to open
the pieceSound
file.
Actions
Required
The pieceSound
should be
converted to a
.wav file instead
of a .mp3 file.
The pygame.mixer.Sound module does not support .mp3 files. Other files which were .wav played so
the pieceSound should also be converted into .wav file from a .mp3 file for it to be played in the game.
So, I have converted the file and loaded it with the changed file type.
Test
number
Test description
Checking that all
sounds are
(Retest)
(Video14) played at their
specified time in
the game and the
background
music continues
to play until the
game is over.
37
Expected
outcome
The sound effects
should play at
their satisfied
time in the game
and background
music should
continue while
gameOver isn’t
true.
Justification
Actual outcome
If the sound
effects and music
doesn’t play at the
right point then
that will bring
down the overall
gaming
experience.
Successful test,
as all the sounds
played at their
specified time
and background
music continued
until the game
was over.
Actions
Required
N/A
TESTING VIDEOS
Test
Description
Checkmate
Test Video
No. No.
32
11
Link
Status
https://youtu.be/V5ttHhiHBOE
Passed
Page 110 of 145
Promotion
34
12
https://youtu.be/u4shf6vykkY
Passed
GuidingPointer
36
13
https://youtu.be/dL8rSqfK70U
Passed
Sound Effects
37
14
https://youtu.be/ZA3ONDq-M34
Passed
STAKEHOLDERS FEEDBACK
As at this point all of core functionality has been developed and most of desirable features have been
implemented therefore, I have decided to get feedback from my stakeholders. So, I know what they
think of almost finished product, does it work as they asked. Also, any changes they want to be
implemented in future development.
Questions
Sayem
Ali
Conclusion
What are your
thoughts about the
guiding pointer?
The guiding pointer
really adds to gaming
experience and at the
same time makes the
game easier.
Enemy pieces that can
be eliminated would be
highlighted with a
different colour in
future development.
How do you find the
usability guiding
pointer?
In terms of usability
colors should be
changed to let colour
blind people use it.
Are you happy with
sound effects added do
you think they are in
line with theme of
game?
The sounds effects suit
the theme of the game.
I feel some sort of
sound effect should be
added to acknowledge
that game is in
checkmate state.
I will like the game to a
mode where a player
can play against
computer AI.
To further enhance the
gaming experience the
guiding pointer should
highlight an enemy
piece red if it can be
eliminated.
I am happy with
usability it is easy to use
and transparent enough
to see both highlighting
and piece at the same
time.
The sounds effects are
good. The background
music is great as it
matches the theme of
the game and adds
intensity to the
gameplay.
It would be great if the
player has the option to
choose from multiple
colour combinations for
the board.
What other desirable
features would you
wish to be added in
future?
Colours maybe changed
in future to allow
maximum audience
take advantage of this
feature.
A sound would be
added that would be
played every time the
game is in checkmate
state.
The option to choose
different colour
combinations for the
board and player vs
computer mode would
be added in future.
Page 111 of 145
EVALUATION
As the coded solution has been completed its time to evaluate the final product. This would be helpful in
maintaining the game and will also provide aid in future development. At this stage we would overlook
what has been achieved and is it in line with what was planned earlier. Could it have been done in a
better way and would it be able to adapt any changes in future. This would be done by comparing the
final solution to the tests I planned before the start of development, feedback from the stakeholders,
assessing the usability and overall, how I feel the project went.
POST DEVELOPMENT TESTING
The first part of evaluation process is to carry out the tests laid out for user and usability in my design.
All of these would be carried out by the stakeholders themselves and some other gaming friends.
MAIN MENU
Test
Number
Testing
Expected Outcome
Justification
Actual Outcome
1
The background
image for main
(Video1) menu screen is
loaded properly
in line with
proportions of
screen size.
The background image
for the main menu
screen fits the whole
screen and no parts of
the screen are left
blank.
If the background
image is not loaded
properly the main
screen would look
inconsistent and
would make it less
appealing.
Successful test, the
background image was
loaded properly and
made the main screen
look consistent.
2
The buttons are
of same size and
(Video1) on the main
screen are
centrally aligned.
The buttons should have
same size and should be
in the center of screen
and vertically from a
column.
If the buttons are
not centrally
aligned and
different sizes the
main screen would
look inconsistent.
Successful test, the
buttons were of the
same size, and all were
centrally aligned and
formed a column.
3
The buttons
highlight when
(Video1) the cursor is
placed on them.
The buttons are
highlighted with a
different color when the
cursor is brought onto
the button.
The buttons
highlighting will
indicate the user
which button they
are currently on.
Successful test, the
buttons highlighted with
a different color to the
button when the cursor
was brought on them.
The game starts
when “PLAY”
(Video2) button is pressed.
A game of chess should
start when the “PLAY”
button is pressed.
If the “PLAY” button
doesn’t initiate the
game the user
would be unable to
play the game.
Successful test, a game
of chess was initiated
when the “PLAY” button
was pressed.
The player should be
navigated to info screen
when “INFO” button is
pressed.
For the user to be
able to access info
page the “INFO”
button should
function properly.
Successful test, the info
page was loaded when
the “INFO” button was
pressed.
4
5
The info screen
loads when the
“INFO” button is
pressed.
Page 112 of 145
6
The game is
terminated when
“QUIT” button is
pressed.
The player should exit
from the game when
“QUIT” button is
pressed.
For the user to exit
the game the
“QUIT” button
should function
properly.
Successful test, the
game was closed when
the “QUIT” button was
pressed.
BOARD SETUP
Test
Number
Testing
Expected
Outcome
Justification
Actual Outcome
1
The board
contains 64
squares of
alternating color
square next as an
8 by 8 grid.
An 8 by 8 grid of 64
squares loads with
alternating squares of
light and dark colors.
The actual chess
board setup is like
this so for a proper
game to be played
the board setup
should be accurate.
Successful test, the
board imitated the look
of an actual chess board
with squares of
alternating dark and
light colors.
2
Both players are
given 16 pieces in
the start of the
game.
Both players are
allotted 16 pieces of
one color before the
start of the game.
This is necessary as
both players are
allotted 16 pieces in
an actual game of
chess.
Successful test, both
players were allotted 16
pieces each with each
player given a different
color for their set of
pieces.
3
Each player has 8
pawns and 1 king
and 2 of queen,
bishop, knight,
and rook.
The specified number
for different pieces is
loaded on the board.
For a proper game of
chess to take place
each player should
be allotted these
number of different
pieces.
Successful test, the
following pieces loaded
in the number described
earlier.
The pawns should take
all squares in the row
of second column from
each side. Rook on
corners of first row of
either side followed by
bishop, knight, king,
and queen.
For the game to
imitate a real chess
game the pieces
should be spawned
at their specified
positions.
Successful test, the
piece spawned on their
specified positions on
the board.
The pieces are
spawned at their
(Video2) specific position.
4
Page 113 of 145
PAWN MOVEMENTS
Test
Number
Testing
Expected Outcome
Justification
Actual Outcome
1
The pawn can
move two
(Video5) squares vertically
forward when in
starting position.
The pawn should be
able to move two
squares forward
vertically when in its
starting position.
In chess a pawn is
allowed to move
two squares
forward when it is
at its starting
position.
Successful test, the
pawn was allowed to
move two squares
vertically forward when
at starting position.
2
The pawn can
move one square
(Video5) vertically forward
when in starting
position.
The pawn should be
able move one square
forward vertically when
in its starting position.
In chess a pawn is
allowed to move
one square forward
when it is at its
starting position.
Successful test, the
pawn was allowed to
move one square
vertically forward when
at starting position
3
The pawn can’t
move two
(Video5) squares vertical
after starting
position.
The pawn should only
move one square
forward vertically when
not at its starting
position.
In chess a pawn is
allowed to move
one square forward
after it has moved
from its starting
position.
Successful test, the
pawn was not allowed
to move two squares
vertically forward when
not at starting position.
The pawn can
only eliminate
(Video5) enemy piece one
square diagonally.
The pawn should
eliminate an enemy
piece if it is one square
diagonally forward.
In chess a pawn can
only eliminate an
enemy piece if it is
one square
diagonally forward
to the current
position.
Successful test, the
pawn was only allowed
to eliminate an enemy
piece if it was one
square diagonally
forward.
4
ROOK MOVEMENTS
Test
Number
Expected Outcome
Justification
1
The rook can
move vertically to
(Video6) any number of
squares if no
piece in path.
The rook should be able
to move any number of
squares vertically in a
column if no other piece
in between.
In chess it is valid
for a rook to move
any number of
squares vertically in
the same column.
Successful test, the rook
was allowed to any
number of squares
vertically when no other
piece in between.
The rook can
move vertically to
(Video6) any number of
squares if no
piece in path.
The rook should be able
to move any number of
squares horizontally in a
row if no other piece in
between.
In chess it is valid
for a rook to move
any number of
squares horizontally
in the same row.
Successful test, the rook
was allowed to any
number of squares
horizontally when no
other piece in between.
2
Testing
Actual Outcome
Page 114 of 145
3
The pawn can
eliminate an
(Video6) enemy piece
horizontally.
The rook should be able
to eliminate an enemy
piece if it is in the same
row and no pieces in
between.
In chess a rook can
capture an enemy
piece horizontally if
no pieces in
between.
Successful test, the rook
was able to eliminate an
enemy piece when on
same row and no pieces
in between.
4
The pawn can
eliminate an
(Video6) enemy piece
vertically.
The rook should be able
to eliminate an enemy
piece if it is in the same
column and no pieces in
between.
In chess a rook can
capture an enemy
piece vertically if no
pieces in between.
Successful test, the rook
was able to eliminate an
enemy piece when on
same column and no
pieces in between.
5
The rook can’t
jump over its own
(Video6) piece.
The rook shouldn’t be
able to jump over an
ally piece.
In chess a rook
piece isn’t allowed
to take a square by
jumping over an ally
piece.
Successful test, the rook
was unable to jump
over an ally piece.
The rook can’t
jump over an
(Video6) enemy piece.
The rook shouldn’t be
able to jump over an
enemy piece.
In chess a rook
piece isn’t allowed
to take a square by
jumping over an
enemy piece.
Successful test, the rook
was unable to jump
over an enemy piece.
6
BISHOP MOVEMENTS
Test
Number
Expected Outcome
Justification
1
The bishop can
move diagonally
(Video7) right to any
number of
squares if no
piece in path.
The bishop should be
able to move any
number of squares
diagonally to right if no
pieces in between.
In chess a bishop
can move any
number of squares
diagonally to right if
no pieces in
between.
Successful test, the
bishop was allowed to
take a square diagonally
to its right when no
other piece in its path.
2
The bishop can
move diagonally
(Video7) left to any
number of
squares if no
piece in path.
The bishop should be
able to move any
number of squares
diagonally to left if no
pieces in between.
In chess a bishop
can move any
number of squares
diagonally to left if
no pieces in
between.
Successful test, the
bishop was allowed to
take a square diagonally
to its left when no other
piece in its path.
The bishop can
only eliminate
(Video7) enemy piece
diagonally.
The bishop should be
able to eliminate an
enemy piece diagonally
if no pieces in between.
In chess a bishop
can eliminate an
enemy piece
diagonally to any
direction if no other
pieces in between.
Successful test, the
bishop was allowed to
eliminate an enemy
piece if was on a square
diagonal to the bishop
with no pieces in
between.
3
Testing
Actual Outcome
Page 115 of 145
4
The bishop can’t
jump over its own
(Video7) piece.
The bishop shouldn’t be
able to jump over its ally
piece.
In chess a bishop
piece isn’t allowed
to take a square by
jumping over an ally
piece.
Successful test, the
bishop wasn’t allowed
to take a square in
which it had to jump
over an ally piece.
The bishop can’t
jump over an
(Video7) enemy piece.
The bishop shouldn’t be
able to jump over an
enemy piece.
In chess a bishop
piece isn’t allowed
to take a square by
jumping over an
enemy piece.
Successful test, the
bishop wasn’t allowed
to take a square in
which it had to jump
over an enemy piece.
Justification
Actual Outcome
5
KNIGHT MOVEMENTS
Test
Number
Testing
Expected
Outcome
1
The knight can
move two
(Video9) squares vertically
and one square
horizontally from
its position.
The knight should be
able to take a square
such that its path
forms a vertical L.
In chess a knight can
only move by moving
one square in one
direction in two
squares in the other
direction.
Successful test, the
knight was able to take
a square for which it
had to move two
squares vertically and
one square horizontally.
2
The knight can
move two
(Video9) squares
horizontally and
one square
vertically from its
position.
The knight should be
able to take a square
such that its path
forms a horizontal L
shape.
In chess a knight can
only move by moving
one square in one
direction in two
squares in the other
direction.
Successful test, the
knight was able to take
a square for which it
had to move two
squares horizontally and
one square vertically.
3
The knight can
only eliminate
(Video9) enemy piece with
its valid moves.
The knight should be
allowed to eliminate
an enemy piece if it is
on square which the
knight can take
legally.
If an enemy piece
exists on a square
where the knight can
move to legally then
the knight should be
allowed to eliminate
that piece.
Successful test, the
knight was allowed to
eliminate an enemy
piece if it was on square
which the knight could
move to legally.
The knight can
jump over its own
(Video9) piece.
The knight should be
allowed to take a
square for which it
has to jump over its
ally piece.
In chess, knight is the
only piece which could
take a square by
jumping over its ally
piece.
Successful test, the
knight was able to take
a square for which it
had to jump over an ally
piece.
4
Page 116 of 145
The knight can
jump over an
(Video9) enemy piece.
5
The knight should be
allowed to take a
square for which it
has to jump over its
enemy piece.
In chess, knight is the
only piece which could
take a square by
jumping over an
enemy piece.
Successful test, the
knight was able to take
a square for which it
had to jump over an
enemy piece.
QUEEN MOVEMENTS
Test
Number
Testing
Expected
Outcome
Justification
Actual Outcome
1
The queen can
move vertically to
(Video8) any number of
squares if no
piece in path.
The queen should be
able to move any
number of squares
vertically if no piece
in between.
In chess it is valid for a
queen to move any
number of squares
vertically in the same
column if no pieces in
between.
Successful test, the
queen was allowed to
move any number of
squares vertically when
no pieces in between.
2
The queen can
move horizontally
(Video8) to any number of
squares if no
piece in path.
The queen should be
able to move any
number of squares
horizontally if no
piece in between.
In chess it is valid for a
queen to move any
number of squares
vertically in the same
row if no pieces in
between.
Successful test, the
queen was allowed to
move any number of
squares horizontally
when no pieces in
between.
3
The queen can
move diagonally
(Video8) right to any
number of
squares if no
piece in path.
The queen should be
able to move any
number of squares
diagonally to right if
no piece in between.
In chess a queen can
move any number of
squares diagonally to
right if no pieces in
between.
Successful test, the
queen was allowed to
move any number of
squares diagonally to
right when no pieces in
between.
4
The queen can
move diagonally
(Video8) left to any
number of
squares if no
piece in path.
The queen should be
able to move any
number of squares
diagonally to left if no
piece in between.
In chess a queen can
move any number of
squares diagonally to
left if no pieces in
between.
Successful test, the
queen was allowed to
move any number of
squares diagonally to
left when no pieces in
between.
5
The queen can’t
jump over its own
(Video8) piece.
The queen shouldn’t
be able to take a
square for which it
has to jump over its
ally piece.
In chess a queen piece
isn’t allowed to take a
square by jumping
over an ally piece.
Successful test, the
queen wasn’t allowed to
a square for which it
had to jump over an ally
piece.
The queen can’t
jump over an
(Video8) enemy piece.
The queen shouldn’t
be able to take a
square for which it
has to jump over an
enemy piece.
In chess a queen piece
isn’t allowed to take a
square by jumping
over an enemy piece.
Successful test, the
queen wasn’t allowed to
a square for which it
had to jump over an
enemy piece.
6
Page 117 of 145
The queen can
eliminate an
(Video8) enemy piece with
its valid moves.
7
The queen should be
to eliminate an
enemy piece if it
exists on a position
which the queen
could move to by a
valid move.
In chess a queen is
allowed to eliminate
an enemy piece it is
on square which the
queen can move to by
a valid move.
Successful test, the
queen was able to
eliminate an enemy
piece if it existed on a
square which the queen
can move to legally.
KING MOVEMENTS
Test
Number
Testing
Expected
Outcome
Justification
Actual Outcome
1
The king can
move one square
(Video10) vertically from its
position.
The king should be able
to move one square
vertically in the same
column if it doesn’t put
it under checkmate.
In chess a king is
allowed to move
one square
vertically if it
doesn’t put it under
checkmate.
Successful test, the king
was able to move one
square vertically if the
move doesn’t put it
under checkmate.
2
The king can
move one square
(Video10) horizontally from
its position.
The king should be able
to move one square
horizontally in the same
row if it doesn’t put it
under checkmate.
In chess a king is
allowed to move
one square
horizontally if it
doesn’t put it under
checkmate.
Successful test, the king
was able to move one
square horizontally if
the move doesn’t put it
under checkmate.
3
The king can
move one square
(Video10) diagonally from
its position.
The king should be able
to move one square
diagonally in any
direction if it doesn’t
put it under checkmate.
In chess a king is
allowed to move
one square
diagonally if it
doesn’t put it under
checkmate.
Successful test, the king
was able to move one
square diagonally if the
move doesn’t put it
under checkmate.
4
The king can
eliminate a piece
(Video10) by its valid
moves.
The king should be able
to eliminate an enemy
piece by a legal move if
it doesn’t put it under
checkmate.
In chess a king is
allowed to
eliminate an enemy
piece it is on square
which the king can
move to legally and
won’t put the king
under check.
Successful test, the king
was able to eliminate
an enemy piece if it was
on a square which the
king could move to via a
valid move and
wouldn’t put the king
under checkmate.
The king can’t
make a valid
(Video11) move which puts
it under
checkmate.
The king shouldn’t be
able to make a move
such that it will put the
king under checkmate.
In chess it is illegal
to make a move
which would put
own king under
checkmate.
Successful test, the king
wasn’t allowed to make
a move which would
put it under checkmate.
7
Page 118 of 145
GUIDING POINTER
Test
Number
Testing
Expected
Outcome
Justification
Actual Outcome
1
All the valid
moves for a pawn
(Video13) are highlighted
when a pawn
selected.
When a pawn piece is
selected all the squares
it can move to legally
should be highlighted.
For the player to
know the valid
moves for a pawn
they should be
highlighted.
Successful test, all the
valid moves for that
pawn piece were
highlighted.
2
All the valid
moves for a rook
(Video13) are highlighted
when a pawn
selected.
When a rook piece is
selected all the squares
it can move to legally
should be highlighted.
For the player to
know the valid
moves for a rook
they should be
highlighted.
Successful test, all the
valid moves for that
rook piece were
highlighted.
3
All the valid
moves for a
(Video13) bishop are
highlighted when
a pawn selected.
When a bishop piece is
selected all the squares
it can move to legally
should be highlighted.
For the player to
know the valid
moves for a bishop
they should be
highlighted.
Successful test, all the
valid moves for that
bishop piece were
highlighted.
4
All the valid
moves for a
(Video13) knight are
highlighted when
a pawn selected.
When a knight piece is
selected all the squares
it can move to legally
should be highlighted.
For the player to
know the valid
moves for a knight
they should be
highlighted.
Successful test, all the
valid moves for that
knight piece were
highlighted.
5
All the valid
moves for a
(Video13) queen are
highlighted when
a pawn selected.
When a queen piece is
selected all the squares
it can move to legally
should be highlighted.
For the player to
know the valid
moves for a queen
they should be
highlighted.
Successful test, all the
valid moves for that
queen piece were
highlighted.
6
All the valid
moves for a king
(Video13) are highlighted
when a pawn
selected.
When a king piece is
selected all the squares
it can move to legally
should be highlighted.
For the player to
know the valid
moves for a king
they should be
highlighted.
Successful test, all the
valid moves for the king
piece were highlighted.
All the valid
which would put
(Video13) king under
checkmate are
not highlighted.
A move for any piece
that could put their king
under check shouldn’t
be highlighted when
that piece is selected.
Moves that puts
the king under
checkmate are
illegal and
therefore not be
highlighted.
Successful test, all the
moves for all the piece
which would put their
king under check
weren’t highlighted.
7
Page 119 of 145
When in
checkmate moves
(Video13) which would not
take the game
out of checkmate
are not
highlighted.
8
When the game is
under checkmate all
moves which would
retain the checkmate
shouldn’t be
highlighted.
Moves that retain
the checkmate of
own king are not
valid so shouldn’t
be highlighted.
Successful test, when
game was under
checkmate only moves
that could tackle the
checkmate were
highlighted.
GAME OVER
Test
Number
Testing
Justification
Actual Outcome
The game should end
when one of kings is
under checkmate and
there are no legal
moves to tackle it.
If no legal moves
are available to put
king out of check
then the game
should end.
Successful test, the
game ended when no
legal moves were
available to put a king
out of check.
The game should end
when there are no legal
moves available which
will put either under
checkmate.
If either player
poses no moves
that could put
opposite king under
check then the
game should end.
Successful test, the
game ended when
there were no legal
moves available to put
either king under check.
When game has been
ended by either case
the game over screen
should be loaded.
The game over
screen should load
to notify the
players that the
game has ended.
Successful test, the
game over screen
loaded when game
ended via either case.
The draw
message is
displayed on the
game over screen
when game ends
via stalemate.
If a game has ended by
stalemate a message
should appear on game
over screen which
confirms that game is
drawn under stalemate.
If game has ended
via stalemate then
the players should
be notified of this.
Successful test, a
message confirming
that game has ended
via stalemate was
displayed when game
ended via checkmate.
The winner
message is
(Video11) displayed on the
game over screen
when game ends
via checkmate.
If the game has ended
by checkmate then the
winner announcing
message should appear
on the game over
screen.
If the game ends by
checkmate then
winner should be
announced so the
players know who
won.
Successful test, a
winner was announced
when game ended by
one player putting
other player under
checkmate.
The game ends
when checkmate
(Video11) is true, and no
legal moves could
be made.
1
2
The game ends
when stalemate
is true.
The game over
screen loads
(Video11) when the game
ends.
3
4
5
Expected
Outcome
Page 120 of 145
PAWN PROMOTION
Test
Number
Testing
Expected
Outcome
Justification
Actual Outcome
1
The pawn can be
promoted a
(Video12) higher ranked
piece if it reaches
the farthest
position on
board.
If a pawn has reached
the farthest position
then it should be
allowed to be promoted
to a higher ranked
piece.
In chess if a pawn
piece reaches the
end row of the board
then it should be
promoted a higher
ranked piece.
Successful test, the
pawn was promoted
to a higher ranked
piece upon reaching
the end row of the
board.
2
The player is
presented with a
(Video12) selection box
which have 4
options to choose
from.
When a pawn is to be
promoted the player
should be presented
with 4 options(Queen,
Knight, Bishop, and
Rook) to choose which
piece type they want
the pawn to promote
to.
For the player to
choose which piece
type they want the
pawn to be
promoted to them
should be presented
with a choice box to
confirm their choice.
Successful test, the
player was presented
with a choice box
containing the 4
options mentioned
earlier.
3
The pawn is
promoted to a
(Video12) queen piece if
queen option is
selected from the
selection box.
When the player has
chosen the queen
option from the
selection box the pawn
should be replaced with
a queen piece on the
board.
Once the player has
chosen which type of
piece they want the
pawn to be
promoted to the
pawn should be
replaced with the
chosen piece type.
Successful test, the
pawn was promoted a
queen piece when the
queen option was
confirmed by the
player.
4
The pawn is
promoted to a
(Video12) bishop piece if
bishop option is
selected from the
selection box.
When the player has
chosen the bishop
option from the
selection box the pawn
should be replaced with
a bishop piece on the
board.
Once the player has
chosen which type of
piece they want the
pawn to be
promoted to the
pawn should be
replaced with the
chosen piece type.
Successful test, the
pawn was promoted a
bishop piece when the
bishop option was
confirmed by the
player.
The pawn is
promoted to a
(Video12) rook piece if rook
option is selected
from the
selection box.
When the player has
chosen the rook option
from the selection box
the pawn should be
replaced with a rook
piece on the board.
Once the player has
chosen which type of
piece they want the
pawn to be
promoted to the
pawn should be
replaced with the
chosen piece type.
Successful test, the
pawn was promoted a
rook piece when the
rook option was
confirmed by the
player.
5
Page 121 of 145
The pawn is
promoted to a
(Video12) knight piece if
knight option is
selected from the
selection box.
6
When the player has
chosen the knight
option from the
selection box the pawn
should be replaced with
a knight piece on the
board.
Once the player has
chosen which type of
piece they want the
pawn to be
promoted to the
pawn should be
replaced with the
chosen piece type.
Successful test, the
pawn was promoted a
knight piece when the
knight option was
confirmed by the
player.
SOUND FEATURES
Test
Number
Testing
Expected
Outcome
Justification
Actual Outcome
1
The background
music keeps
(Video14) playing until the
game finishes.
When the game has
started the background
music should start to
play and it should be
kept playing until the
game ends.
The background
music during game
would enhance the
gaming experience
and make the game
more appealing.
Successful test, the
background music
started as the game
started and kept playing
until the game ended.
2
The piece
movement sound
(Video14) is played
whenever a piece
is moved.
When a piece has been
moved then the piece
movement sound
should be played.
This sound would
notify the player
that the piece has
been successfully
moved.
Successful test, the
piece movement sound
was played when a
piece was moved on
the board.
3
The promotion
sound is played
(Video14) when a pawn is
promoted a
higher ranked
piece.
When a pawn has been
successfully promoted
to a higher ranked
piece the promotion
sound should be
played.
This sound would
notify the player
that the pawn has
been successfully
promoted to a
higher ranked
piece.
Successful test, the
promotion sound was
played when a pawn
was successfully
promoted to a higher
ranked piece.
The game over
sound is played
(Video14) when the game
ends by any form
of termination.
When a game has
ended via any form the
game over sound
should be played.
This sound will
notify the player
that the game has
ended, and no
moves could be
made now.
Successful test, the
game over sound was
played when the game
ended by any form of
termination.
4
Page 122 of 145
SOLUTIONS’ COMPARISON TO SUCCESS CRITERIA
To evaluate my solution in more depth I want to compare my solution to success criteria which I
described in my analysis. Doing this will assist me assessing if the project was successful or not. I will
individually assess each of the criterion and first determine whether I completely, partially or didn’t
meet the specific criterion. To expand on this, I will justify the reasons for my judgement and set out any
future plans to tackle partially or unmet criterion.
Criteria
Justification
The chess pieces can move on
the board.
The player must be able to
move the pieces across the
board to play the game.
Criteria met?
Completely MET
According to my judgment this criterion was completely met. This judgment is based upon the results
from the development test 4 (video2) , this test was passed as the player was able to move pieces on
the board.
Criteria
Justification
The board is setup like real
chess board.
The board setup is necessary as
otherwise problems will arise
with moving pieces which will
affect the gameplay.
Criteria met?
Completely MET
This criterion is completely passed as well. The board is setup like an actual chess board and the pieces
are spawned at right positions. The evidence for this is development test 2 and 3. The stakeholders
commented that the board setup looks very realistic and doesn’t require any improvement.
Criteria
Justification
A piece can eliminate another
piece.
In order the game to work like
an actual chess game, player
must be able to eliminate other
player’s pieces.
Criteria met?
Completely Met
In my view sufficient evidence is able to confirm that this criterion has been completely met.
Development test 6 (video 3) testifies this claim. A piece was able to eliminate another piece hence this
criterion is completely met.
Criteria
Justification
The player can perform an en
passant capture using a pawn
piece.
En passant is type of capture
move in chess which involves
pawns only. It is allowed in a
real game so the player should
be able to perform it here as
well.
Criteria met?
Not Met
Page 123 of 145
I believe that this criterion hasn’t been met at all. The reason for this criterion not being achieved was
lack of understanding of the feature itself and how this can be achieved logically. To achieve this
criterion, I will interview my stakeholders on this feature and do more research and then try to execute
it in future development.
Criteria
Justification
The pieces stay within the
bounds of the board.
If the piece would leave the
board while making a move it
would not be realistic as a piece
cannot make a move on
position which is not on the
board.
Criteria met?
Completely Met
According to my judgment this criterion has been successfully achieved. This is confirmed in
development test 3 as when a click was made outside the bound of the board after selecting a piece the
piece stayed in its original position confirming it doesn’t go off the bound.
Criteria
Justification
The player can see possible
moves they can make when
they select a particular piece
This is more of a desirable
feature but is useful as it will
allow the user to know what
possible moves can be made if
they are unsure.
Criteria met?
Completely Met
The feedback from the stakeholders and the results of development test 35 (video 13) and post
development (guiding pointer section) confirms that this criterion has been successfully met. The
squares representing valid move for a piece were highlighted so its objective achieved.
Criteria
Justification
In time modes it displays the
remaining time.
If the timer is not available in
the time mode than the player
will not be able to keep track of
remaining time.
Criteria met?
Not Met
This criterion hasn’t been met at all. The reason for this was limited time frame for developing the
project. As this was one of the desirable features, features which were essential took priority, so it was
never implemented in the game. I have planned to execute this feature as a part of future development
Criteria
Justification
The game ends when the king
cannot escape (Checkmate).
This is one of the main
objectives of the game as a win
cannot be attained without
capturing another player’s king.
Criteria met?
Completely Met
Page 124 of 145
According to my judgment this criterion has been completely met. The feedback from the stakeholders
and the results of development test 31 (video 11) and post development test(game over section) test 1
provides the evidence for this judgment. The game ended when game was in checkmate and no more
pieces could be moved to counter the checkmate.
Criteria
Justification
The game ends when there are
no valid moves to be made
(Stalemate).
If no legal moves can be made
to checkmate the king, the
game should end as that is what
would happen in a real game of
chess.
Criteria met?
Completely Met
The feedback from the stakeholders and the results of development test 32 (video 11) and post
development test(game over section) test 2 provides enough evidence that this criterion has been
successfully met. The game ended when there were no valid moves available, and the game wasn’t in
checkmate position.
Criteria
Justification
The player can resign the game
using a resign button and win
should be awarded to the other
player.
If at any point a player wishes to
resign, they should have the
option to do so, and win should
be awarded to other player. As
this is what would happen in a
real game.
Criteria met?
Not Met
This criterion hasn’t been met. The reason being limited time for implementing this feature while also
developing other necessary core functionality for the project. This feature would be implemented as a
part of future development.
Criteria
Justification
If a pawn reaches the farthest
position on the board, it can be
promoted to a higher rank
piece.
In case a pawn reaches the
other end of the board it should
be promoted to a higher rank
piece such as a queen. This is
because that is what would
happen in a real game of chess.
Criteria met?
Completely Met
This criterion has been successfully met. The results of development test 33 (video 12), post
development test (promotion section) and the feedback from the stakeholders confirms that this
criterion has been completely met. The pawn was promoted to a higher rank piece.
Page 125 of 145
Criteria
Justification
The player gets the option to
choose the type of piece they
want their pawn to be
promoted to.
To promote the pawn, the
player must choose what type
of piece they want it to be
promoted to so some form of
choice input system would be
required.
Criteria met?
Completely Met
The results from the development test 34 (video 12), post development test (promotion section) test 2
and the feedback from the stakeholder suggests that this criterion has been met successfully. The player
was presented with a choice box to register their choice.
Criteria
Justification
The player can perform castling
if it is a valid move.
Castling is one of the legal
moves in chess where a king can
crossover a rook in a certain
way. It is valid move and player
should be able to perform it in
the game.
Criteria met?
Not Met
This criterion hasn’t been met. The reason being the complication of the task and the time available to
execute it. More time would be required to establish a logic which successfully achieves the objective.
This would be implemented in future development.
Criteria
Justification
The player is only allowed to
make valid moves and invalid
moves are not executed.
For a fair and fully functioning
game to take place it is
necessary that only valid moves
allowed while invalid are
discarded.
Criteria met?
Completely Met
This criterion has been completely met. The evidence for this judgement is result of development test
(12,17,21,24,252,26,27) . The valid moves for each piece were allowed while invalid moves were
disallowed, and player was asked to make a different move.
Criteria
Justification
The game should end as a draw
if no elimination has been
made or no pawn has been
moved in the last 50 moves.
Fifty-move-rule is a rule in
chess. This allows either player
to claim a draw under certain
circumstances. So, this form of
termination should be allowed.
Criteria met?
Partially Met
The criterion has been implemented partially. The game ended as draw when any of these conditions
were found to be true, but the user wasn’t presented with an option to actually claim a draw. So only a
graphical implementation where the player is asked to accept is required.
Page 126 of 145
Criteria
Justification
When in checkmate all moves
that would not take it out of
checkmate should be
disallowed.
It is invalid to make a move
which will keep the king under
checkmate so moves that result
in this should be disabled until
king comes out of check.
Criteria met?
Completely Met
The results of development test 30, post development test (guiding pointer) test 7 and the stakeholders’
feedback provide evidence that this criterion has been successfully met. The player wasn’t allowed to
make any move which will retain the checkmate.
LIMITATIONS OF SOLUTION
The solution required that the chess board takes the whole game screen else errors will appear when
the player tries to click outside the board boundary after a piece has been selected to move. This limits
me from implementing other essential features like the resign button and player icons. The resign
button is required to ben next to each players’ icon. The player icon is supposed to be on the either side
of the board. As the board itself takes the whole game screen it doesn’t allow the player icon to be
added onto the screen. If implemented with the current setup the player icon would be overlapping
with some part of the board which will not allow the player to make the moves whose squares are
under the player icon. So, for this feature to be implemented the limitation of board limiting access to
other part of game screen should be tackled.
CHANGES DURING DEVELOPMENT
The implementation of how the promotion choice would be presented was changed during the
development. In the design stage it was planned to be a keyboard input to enter a promotion choice.
This was implemented but caused the program to crash multiple times. For this reason, I had to come up
with an alternative method of registering players’ choice for the promotion of pawn. So, instead of
navigating back to the visual studio code terminal the player was presented with a selection box which
registered the choice just by clicking to the option you want the pawn to be promoted to. This enhanced
the gaming experience as it was done graphically and also allowed the program to run smoothly.
USABILITY FEATURES
The core to any good game is an intuitive design and any easy-to-use UI. The usability features play a
vital role in achieving this. In this section the usability features introduced in the game would be
discussed. The reason for implementing them would be justified. To evaluate their implementation
feedback would be taken from stakeholders to ensure that they are satisfied with the features and how
would they rate each feature in terms of making the game easier to interact with.
Page 127 of 145
Feature
Justification
Stakeholders Feedback
Piece Selection
Highlighting
The selected piece being highlighted
would let the player know that the
piece they wanted to select is actually
selected or not.
Sayem: The selected piece highlight is
useful in determining whether right
piece has been selected or not.
The highlighting of valid moves will take
away all the invalid moves so the player
can know the move they wanted to
make is allowed or not.
Sayem: The valid move highlighting
would be more useful if opponent
pieces that can be eliminated are
highlighted by a different color.
Valid Move
Highlighting
Ali: This adds usability and also at the
same enhances the gaming
experience.
Ali: I think in addition to valid moves
being highlighted the king piece
should be highlighted as well with a
different color if under checkmate.
Button
Highlighting
Color of buttons
Color of board
Undoing move by
z key
The buttons are highlighted with
another color when the user puts the
cursor on it. This will let user know
which button they are going to press.
Sayem: I found it to be useful and felt
that it makes the game more
appealing.
The color of buttons is set to be brown,
so it matches the theme of the game
and also allows people with color
blindness to easily spot them.
Sayem: Brown color for buttons looks
high in contrast and makes the game
inclusive to color blind people as well.
Choosing saddle brown and sandy
brown for the square colors on board
ensures that the board is high in
contrast so easy to see. Also, these
colors are easily seen by color blind
people.
Sayem: The color combination of
board is appealing and attracts would
attract more audience as inclusive for
color blind people.
Pressing z key for undoing a move is
easy and quick. The reason of selecting
z key for this is that ctrl+z is often used
to undo anything, so it would easier for
the player to remember.
Sayem: This feature is really useful as
accidental moves can be taken back.
But I think maybe “u” key would have
been a better choice to use this
feature.
Ali: The button highlight looks cool
and enhances the interactive features
of the game.
Ali: This suits the theme of the game
and at the same time makes using
buttons easier to use for everyone.
Ali: Board being high in contrast
allows easy visibility and the choice of
colors gives a classic vibe.
Ali: Choosing “z” key for this is smart
as it links to the key for generally
undoing a thing. Also, it is very easy to
use.
Page 128 of 145
Selection box
with prewritten
options
The graphical appearance of selection
box with prewritten option ensures that
the player can make their choice easily
and aren’t required to type the choice
themselves in.
Sayem: I feel this is very useful as it
reduces the unnecessary effort of
manually typing in the name of the
piece from the player.
Ali: I find it easy to use but would
prefer pieces pic next to option so the
interface looks more appealing.
UNMET USABILITY FEATURES
Valid move color: The valid moves are currently being highlighted by green color. This will result in
people with color blindness unable to take advantage of the guiding pointer feature. This needs to be
changed so such color is chosen that people with color blindness can easily use this feature.
Player icon: The player icons should be added with players’ name and piece color allocated next to it.
This would let the player distinct which piece color belongs to them. The player icon should be
highlighted when the players’ turn starts. This would make it easier for the players to spot whose turn it
is to move.
Last move highlight: Highlighting the last move of the opposite player when ones player turns arrive
should be added. This would be useful in keeping a track of progression of game and will also enhance
the gaming experience. This allows the player not to be obliged to looking at game screen until
opponent has made their move as they could just know what move opponent has made by looking at
the highlighted path of the opponents’ piece.
FUTURE MAINTENANCE
In future the stakeholders plan to introduce some new features to the game to expand the audience.
Implementing these features would require some changes in existing features. Also, some existing
features can be implemented in a better manner which would make the game faster and smoother. All
of this would discuss in this part of evaluation including description of new features how I plan to
implement and test them and how existing features would be maintained.
MAINTAING THE SYSTEM (PERFECTIVE AND ADAPTIVE)
For maintaining the current system and making it run faster I have decided to make a few maintenance
jobs. These maintenances are focused towards making the game easier to play so the gaming
experience can be further enhanced. These maintenance jobs are divided into three types which are
corrective, adaptive and perfective.
PERFECTIVE MAINTENANCE
The first one is to make a few modifications to the move validation process. As I have noticed that for
generating valid moves for rook, bishop, queen, and king similar format is reused several times. For this I
have decided to make a single function which generates moves for these pieces by just taking one
Page 129 of 145
variable direction which would vary from piece to piece. Doing this would reduce the size of the function
and need to rewrite the same function several times. So, would reduce the size of game resulting in
same functionality to be achieved in much less processing.
The En passant capture also needs to be implemented. The pawn was able to perform elimination by
other form, but this wasn’t allowed. So, another function needs to be included in the pawn moves which
checks if en passant is possible and allows it if a player tries to execute it.
ADAPTIVE MAINTENANCE
The second maintenance task is to adapt the graphical user interface to the ones available in modern
games. This is to do with the selection box for the promotion choice. The current system just offers a
plain text box for the selection of promotion choice. This would be replaced by an upgraded version of
selection box which is more appealing as it would contain the image of the piece along the name and
would be presented on the side of the board instead of side of the screen.
CORRECTIVE MAINTENANCE
The third part of this process is to fix the errors in the features which weren’t implemented successfully.
The first feature which needs this kind of maintenance is the fifty-move rule. Even though the game
ended as draw when it was true, but the players weren’t presented with an option to make use of this
feature. For this a button would be added which would only be usable when this condition is true. So, by
pressing it the player would be able to claim the draw.
The castling was another feature which wasn’t implemented successfully. To fix this an additional
parameter would be required in the valid moves functions for the rook and the king. This would check if
this move can be made and if true this would move the king and the rook simultaneously so the king can
move two squares towards the rook and the rook moves to the square that the king has crossed.
POSSIBLE FUTURE FEATURES
Some new features would also be introduced in the future along with those features which weren’t
implemented in previous development due to lack of time.
Disabling pointer: If the player feels that they don’t need the guiding pointer this feature would just
disable the feature for only that player while the other player would still be able to make use of the
guiding pointer.
Different color option: This feature will allow the player to decide what color combination they want for
the board. A set of premade combinations would be available to choose from and the player would be
able to select any combination before the start of the game.
Computer vs Human mode: This feature will allow a player to play against computer bot with artificial
intelligence. There would be different levels of bots available ranging from beginner to master. The
player would be able to play against the bot of their choice of level.
Page 130 of 145
Time modes: The time modes were to be implemented before, but this objective wasn’t achieved due to
the lack of time. So, this feature would be implemented now as it was supposed to be implemented in
previous development.
LIMITATIONS OF POSSIBLE FUTURE FEATURES
The implementation of Computer vs Human modes would depend upon the development of artificial
intelligence for different levels of bot. This would be a limitation as this process would require a high
level of understanding of complex programming techniques and would also require a lot of time. For this
reason, other possible features would take priority and development on this feature would start after
those have been implemented successfully as extreme through testing would be required for this.
SUMMARY
Following the completion of the game, a number of development and testing procedures have been
created around the project, which will aid in the ongoing maintenance of the game in the manner
indicated.
It may appear to be ambitious bug fixes while also attempting to incorporate new features, but without
time limits and other variables, effectively rolling out updates will be considerably easier. After reflecting
thoroughly in this section, I've also discovered how to do a lot of coding, testing, and documenting in an
efficient manner, and since that self-criticism is also written down, any future developers trying to
develop from this will find that there were places where things could’ve been done a lot better.
In conclusion, the project created matches and even exceeds stakeholders expectations, I have built up
skills that will help during future maintenance especially while adding new features in future.
Page 131 of 145
PROJECT APPENDIXES
GAME ENGINE
THE BOARD
Page 132 of 145
MAKING AND UNDOING A MOVE
Page 133 of 145
VALID MOVE GENERATION
CHECKING FOR CHECKMATE
Page 134 of 145
GENERATING ALL POSSIBLE MOVES
Page 135 of 145
GENERATING MOVES FOR PAWN
Page 136 of 145
GENERATING MOVES FOR ROOK
GENERATING MOVES FOR BISHOP
Page 137 of 145
GENERATING MOVES FOR KNIGHT
GENERATING MOVES FOR QUEEN
GENERATING MOVES FOR KING
Page 138 of 145
MAIN FILE
Page 139 of 145
BUTTONS AND TEXT
Page 140 of 145
DRAWING BOARD
DRAWING PIECES AND GUDING POINTER
Page 141 of 145
DRAWING GAME STATE
MUSIC AND SOUND FILES
MAIN MENU
Page 142 of 145
GAME LOOP
Page 143 of 145
Page 144 of 145
Page 145 of 145
Download