NEA Analysis (First Draft) - 1
NEA Analysis (First Draft) - 1
Contents
Contents 1
Analysis 4
Interview 4
Background to the Problem 5
Observing existing systems 6
Lichess (lichess.org) 6
Chess.com (chess.com) 9
ChessBase (chessbase.com) 11
Flowcharts 13
Move Validation Flowchart 13
Usability for a chess application 14
Tasks to be Computerised and the Benefits of Computerising 15
Tasks: 15
Qualitative Benefits: 15
Quantitative Benefits: 15
Objectives for the Proposed System 16
Possible SQL Queries 18
Design 20
Generic App Workflow 21
IOPS Chart 22
Hierarchy chart 23
System Flowchart 24
Data Flow Diagram (DFD) 25
Database Schema 26
Entity Relationship Diagram (ERD) 27
Object-Oriented Programming Class Design 28
Class: ChessBoard(QWidget) 29
Class: PromotionWindow(QWidget) 31
Class: Piece 32
Class: Rook (Child of Piece) 32
Class: Bishop (Child of Piece) 33
Class: Knight (Child of Piece) 34
Class: Queen (Child of Piece) 34
Class: Pawn (Child of Piece) 35
Class: ChessPiece(QLabel) 35
Class: ChessBoardUI(QWidget) 36
Algorithms 39
Monte-Carlo (chess engine) 39
Password-Based Key Derivation Function 2 (pbkdf2) 40
1
Jack Cooke A Level Computer Science Project
2
Jack Cooke A Level Computer Science Project
3
Jack Cooke A Level Computer Science Project
Analysis
Interview
Interviewer (Developer): What should the main focus of this chess app be?
Client: The main goal is to make chess as convenient as possible for everyone
to play, anywhere, online, without needing a board or another person.
Interviewer: What about user accounts? Are there any specific requirements?
Client: Definitely. People should be able to create accounts and log in easily.
However, the app needs a robust security system—the app should store user
passwords safely, and robust mitigations are required to block attackers from
gaining access to user accounts.
Interviewer: And for the game itself, what features should we include?
Client: The app should track everything on the board, including where the
pieces are, their type, and even special moves like castling or en passant.
Also, it’d be great if the app could recognise standard openings and suggest
counters.
Client: An Elo rating system similar to chess sites like lichess or chess.com
would be great.
Client: It would be awesome if players could also save or upload games so they
can view them later.
Client: The AI should adapt to the player’s level. It must be tough enough to
keep things fun but not so hard that it is frustrating.
4
Jack Cooke A Level Computer Science Project
For centuries, chess has been a beloved game enjoyed by millions worldwide.
Nevertheless, only some have had the opportunity to participate in this popular
pastime. This initiative strives to enhance chess's accessibility. By evaluating
technological innovations, promoting inclusive chess experiences, and engaging
the chess community, this effort seeks to widen the scope of the chess player
base, making the game more inclusive for all; removing the requirement for a
physical board makes the game more accessible. By making the game online, the
requirement of a similarly skilled human is removed, and the user can play
against a computer with a similar skill.
5
Jack Cooke A Level Computer Science Project
Several students were using chess-playing systems to identify valued features and
usage patterns.
Lichess (lichess.org)
1. User Registration:
2. User Profile:
2.1.1. Allow users to manage and update personal details within their
profiles.
2.2. Preferences:
3. Game Creation:
6
Jack Cooke A Level Computer Science Project
4. Matchmaking:
4.2. Connect players with similar ratings to ensure fair and competitive
gameplay.
5. Gameplay:
6.1.2. Integrate chess clocks to track each player's time during the
game accurately.
7
Jack Cooke A Level Computer Science Project
8
Jack Cooke A Level Computer Science Project
Chess.com (chess.com)
1. User Registration:
1.1. Users are first asked for their skill level: New to Chess,
Beginner, Intermediate, or Advanced.
1.2. Users then enter an email address and password.
1.3. Users then log in with their details.
2. User Profile:
2.1. Profile Information:
2.1.1. Allow users to manage and update personal details within
their profiles and competitive ratings from OTB.
2.2. Preferences:
2.2.1. Users can change them for their game, the colours
for the pieces, and the board.
3. Game Creation:
3.1. Create Game Interface:
3.1.1. Allow users to choose opponents, including the
computer, friends, random opponents,
tournaments or chess variants.
4. Matchmaking:
4.1. Chess.com matches users with similar ELO ratings, where the
amount gained per game is proportional to the difference in rating.
5. Gameplay:
9
Jack Cooke A Level Computer Science Project
10
Jack Cooke A Level Computer Science Project
ChessBase (chessbase.com)
1. User Registration:
1.1. Users enter an email address,
password and username.
1.2. Users log in with their credentials.
2. User Profile:
2.1. Profile Information:
2.1.1. Allow users to manage and update personal details within
their profiles.
3. Game Creation:
3.1. Create Game Interface:
3.1.1. Allow users to choose opponents, including the computer,
friends, random opponents, tournaments or chess variants.
4. Matchmaking:
4.1. ChessBase matchmakes users with similar ELO ratings where the
amount gained per game is proportional to the difference in rating
5. Gameplay:
5.1. Game Board Display:
5.1.1. Displayed a standard board to the user;
white is always on the bottom
5.1.2. Highlights legal moves
6.
6.1. Move Validation:
6.1.1. ChessBase implements rules to validate moves.
11
Jack Cooke A Level Computer Science Project
12
Jack Cooke A Level Computer Science Project
Flowcharts
See Appendix A for observations of existing applications.
13
Jack Cooke A Level Computer Science Project
14
Jack Cooke A Level Computer Science Project
Tasks:
- Board customisation
- Variable difficulty AI
- The post-game analysis allows users to see mistakes
- Detection of standard openings and variations
- Custom themes
Qualitative Benefits:
- Improves the User Interface/user experience and playability
- Facilitates user customisation and improves experience
- Adaptive difficulty, which supports player advancements and prevents
boredom
Quantitative Benefits:
- Ability to cater to any skill level.
15
Jack Cooke A Level Computer Science Project
16
Jack Cooke A Level Computer Science Project
5. AI Player
5.1. The user should be able to play against a chess bot with adaptive
difficulty.
5.2. The bot should be able to challenge the player enough to make the
game fun but not sufficient to make the game too difficult.
17
Jack Cooke A Level Computer Science Project
18
Jack Cooke A Level Computer Science Project
SELECT Player.username,
SUM(CASE WHEN Game.result = 'win' THEN 1 ELSE 0 END) AS wins,
SUM(CASE WHEN Game.result = 'lose' THEN 1 ELSE 0 END) AS losses
FROM Player
LEFT JOIN Move ON Player.player_id = Move.player_id
LEFT JOIN Game ON Move.game_id = Game.game_id
GROUP BY Player.player_id, Player.username;
19
Jack Cooke A Level Computer Science Project
Design
Generic App Workflow
20
Jack Cooke A Level Computer Science Project
IOPS Chart
This chart displays how data flows in input/output, processing, and storage at the
most basic level.
Input Process
Storage Output
21
Jack Cooke A Level Computer Science Project
Hierarchy chart
22
Jack Cooke A Level Computer Science Project
System Flowchart
The flowchart illustrated below shows the process from user login to gameplay,
including storage of moves and promotions.
23
Jack Cooke A Level Computer Science Project
The following diagram, written in UML format, displays the interactions and data
passed between the chess application's components.
24
Jack Cooke A Level Computer Science Project
Database Schema
25
Jack Cooke A Level Computer Science Project
26
Jack Cooke A Level Computer Science Project
class: Piece
x Integer
y Integer
class: Rook
Inherits from Piece
super().__init__(colour)
class: Knight
Inherits from Piece
super().__init__(colour)
class: Bishop
Inherits from Piece
super().__init__(colour)
class: Queen
Inherits from Piece
super().__init__(colour)
class: King
Inherits from Piece
super().__init__(colour)
class: Pawn
Inherits from Piece
super().__init__(colour)
first_move = BOOLEAN (defaults to True)
27
Jack Cooke A Level Computer Science Project
Class: ChessBoard(QWidget)
Identifier / Data Description
__init__
Returns N/A
draw_board (public)
draw_piece
Returns N/A
get_valid_moves
28
Jack Cooke A Level Computer Science Project
calculate_material_score
are_you_in_check
Returns Integer:
0 = No check
1 = Check
2 = Checkmate
move_piece
Returns N/A
29
Jack Cooke A Level Computer Science Project
highlight_squares
Returns N/A
Class: PromotionWindow(QWidget)
Identifier / Data Description
__init__
Returns N/A
piece_selected
Returns self.selected_piece
30
Jack Cooke A Level Computer Science Project
Class: Piece
Identifier / Data Description
__init__
Returns N/A
select
deselect
__init__
Returns N/A
31
Jack Cooke A Level Computer Science Project
get_valid_moves
__init__
Returns N/A
get_valid_moves
32
Jack Cooke A Level Computer Science Project
__init__
Returns N/A
get_valid_moves
__init__
Returns N/A
get_valid_moves
33
Jack Cooke A Level Computer Science Project
__init__
Returns N/A
get_valid_moves
Class: ChessPiece(QLabel)
Identifier / Data Description
__init__
Returns N/A
34
Jack Cooke A Level Computer Science Project
Class: ChessBoardUI(QWidget)
Identifier / Data Description
__init__
Returns N/A
init_login_ui
Returns N/A
handle_login
Returns N/A
show_main_ui
Returns N/A
35
Jack Cooke A Level Computer Science Project
init_ui
Returns N/A
start_timer
Returns N/A
get_valid_moves
Returns N/A
handle_click
Returns N/A
move_piece
Returns N/A
36
Jack Cooke A Level Computer Science Project
ai_move
Returns N/A
update_material_count
Returns N/A
37
Jack Cooke A Level Computer Science Project
Algorithms
MCTS consists of four stages: 1. Selection: The tree is traversed from the root node
until it selects a new leaf node
1. Expansion: Adds a leaf to the tree
2. Simulation: Evaluate the move. The result is either 1, 0, -1
3. Backpropagation: Propagates results through the tree
The most significant issue with the bare implantation of MCTS is the flaw whereby
the program may favour a move that loses due to a statistically unlikely playout
caused by the random nature of MCTS; the usage of UCT mitigates this.
Other limitations of MCTS include the reliance on external models to evaluate the
position, such as Neural Networks or other algorithmic evaluation methods, such
as assigning piece-specific weights to squares. Furthermore, to parse the vast
number of positions in a reasonable time, Alpha-beta pruning and a cap on max
iterations can be introduced since, after ten moves, there are already
~70,000,000,000,0002 possible unique positions. The time complexity of
computing all positions increases exponentially as more moves occur. Alpha-beta
pruning works by defining alpha as beta as the lower bound and alpha as the
upper bound; as the algorithm explores the tree, if a move results in a value worse
38
Jack Cooke A Level Computer Science Project
than the current alpha or beta value, all subtrees from the node are removed,
therefore decreasing the number of nodes to parse and the time to find the best
move.
To properly implement pbkdf2, different salts should be used for each user to
thwart attackers using rainbow tables. Furthermore, adding a pepper to the
opposite end as the salt when hashing a password can prevent an attack that
gained access to the database from being able to decrypt it, providing the pepper
is stored in a secure place such as an HSM.
https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf
https://www.ietf.org/rfc/rfc2898.txt
ISSUES: SEE https://pycryptodome.readthedocs.io/en/latest/src/protocol/kdf.html
39
Jack Cooke A Level Computer Science Project
Python
score = materialWeight * (numWhitePieces - numBlackPieces) * who2move
f(p) = 200(K-K')
+ 9(Q-Q')
+ 5(R-R')
+ 3(B-B' + N-N')
+ 1(P-P')
- 0.5(D-D' + S-S' + I-I')
+ 0.1(M-M')
40
Jack Cooke A Level Computer Science Project
Initial Concepts:
Strengths:
● Readability: The high-contrast colours make the board and pieces easy to
see and understand.
● Aesthetic Appeal: The green squares add a modern twist to the traditional
chessboard design, making it visually appealing.
● Standard Compliance: The setup adheres to standard chess rules.
Potential Improvements:
● Highlighting: Add move highlighting or the ability to show valid moves for
selected pieces to improve interactivity.
● Coordinates: Include board coordinates (e.g., a1, h8) for easier reference
● Colour Customization: Allow users to change the board and piece colours
to suit their preferences.
41
Jack Cooke A Level Computer Science Project
Strengths:
Potential Improvements:
42
Jack Cooke A Level Computer Science Project
Strengths:
Potential Improvements:
Overall:
● This design is worse than the design above due to the colour scheme and
the top bar feeling crowded.
43
Jack Cooke A Level Computer Science Project
System Architecture
44
Jack Cooke A Level Computer Science Project
Technical Solution
45
Jack Cooke A Level Computer Science Project
46
Jack Cooke A Level Computer Science Project
47
Jack Cooke A Level Computer Science Project
Algorithm Implementation
● Monte Carlo Tree Search (MCTS): The mcts.py module implements the
MCTS algorithm for AI decision-making. This involves:
○ Tree Structure: The Node class represents each state in the game
tree, holding information about the board state, parent and child
nodes, visit counts, and value evaluations.
○ Algorithm Phases: The MCTS implementation includes selection,
expansion, simulation, and backpropagation phases. Methods like
select(), expand(), simulate(), and backpropagate() manage these
processes.
○ Heuristic Evaluation: The AI uses the board evaluation function to
simulate and evaluate potential moves.
48
Jack Cooke A Level Computer Science Project
49
Jack Cooke A Level Computer Science Project
50
Jack Cooke A Level Computer Science Project
51
Jack Cooke A Level Computer Science Project
● Data Management:
○ CRUD Operations: The application performs Create, Read, Update,
and Delete operations on the database for managing users, login
attempts, and game records.
○ Prepared Statements: Parameterised queries to prevent SQL
injection attacks.
52
Jack Cooke A Level Computer Science Project
● Testing Frameworks: Utilizes unittest and pytest for writing and executing
test cases.
53
Jack Cooke A Level Computer Science Project
54
Jack Cooke A Level Computer Science Project
55
Jack Cooke A Level Computer Science Project
● Data Handling:
○ Uses the chess.pgn module to parse PGN files efficiently.
○ Manages large datasets by splitting files and processing chunks
asynchronously.
56
Jack Cooke A Level Computer Science Project
57
Jack Cooke A Level Computer Science Project
● PEP 8 Compliance:
○ The codebase adheres to Python's PEP 8 style guidelines, enhancing
readability and maintainability.
● Linting Tools:
○ A fast Python linter, Ruff detects and fixes coding errors and style
issues.
○ Automated linting is integrated into the CI pipeline to enforce code
standards.
58
Jack Cooke A Level Computer Science Project
● Exception Handling:
○ The application includes try-except blocks to handle potential
runtime errors gracefully.
○ Provides informative error messages to assist in debugging.
● Logging:
○ Utilises the logging module to record events, errors, and significant
actions within the application.
○ Log files help in monitoring the application's behaviour over time.
59
Jack Cooke A Level Computer Science Project
60
Jack Cooke A Level Computer Science Project
Networking
The application consists of a client and a server, with the server running on a
remote machine or locally.
Client
The client connects to the server or port 5556 and communicates with the server
using SOCK_STREAM, which uses the Transmission Control Protocol to prevent
data loss between the client and server.
61
Jack Cooke A Level Computer Science Project
Server
The server listens to port 5556 for incoming connections from the client and can
support multiple clients. The server binds to a port and listens for connections.
The server then makes all the moves locally and uses Pickle, a Python serialisation
library, to send Python Objects to the client.
62
Jack Cooke A Level Computer Science Project
● A custom container is built from the following file to run the Python part of
the application.
63
Jack Cooke A Level Computer Science Project
Testing
Overview
This test plan outlines the testing strategy for the chess application. The tests
ensure the system works as expected and meets the specified objectives. The
tests will be automated using pytest and unittest, and the results will be analysed
using SonarQube.
Test Plan
Purpose: Verify the functionality of the database connector. Test Data: Temporary
SQLite database. Expected Outcome: The database tables are created, and data
can be inserted, retrieved, and verified.
64
Jack Cooke A Level Computer Science Project
65
Jack Cooke A Level Computer Science Project
Test Cases:
test_create_users_table:
Description: Verify that the users table is created successfully.
Expected outcome: A table is created with the columns and restrictions specified
in the image below
66
Jack Cooke A Level Computer Science Project
test_insert_user:
Description: Verify that a user can be inserted into the users table.
Expected outcome: A user with the username “test_user” is inserted into the test
table, where a random 16-bit value is the salt and the password is stored as a hash.
test_verify_user:
Description: Verify that user verification works correctly.
Expected outcome: When entering the correct credential, a user can access their
account.
67
Jack Cooke A Level Computer Science Project
test_create_logins_table:
Description: Verify that the logins table is created successfully.
Expected outcome: A table is created with the columns and restrictions specified
in the image below
68
Jack Cooke A Level Computer Science Project
test_insert_login_attempt:
Description: Verify that a login attempt can be inserted into the logins table.
Expected outcome: A table is created with the columns and restrictions specified
in the image below
test_get_login_attempts:
Description: Verify that login attempts can be retrieved from the logins table.
Expected outcome: When a user is inserted into the login attempts table, the
timestamp associated with the login is correct.
69
Jack Cooke A Level Computer Science Project
test_create_games_table:
Description: Verify that the games table is created successfully.
Expected outcome: A table is created with the columns and restrictions specified
in the image below
test_insert_game:
Description: Verify that a game can be inserted into the games table.
Expected outcome: When a game is complete, check that the match inserted into
the table exists and is formatted correctly.
70
Jack Cooke A Level Computer Science Project
See 2:47 - 3:16 in the attached video and 4:41 - 5:12 for demonstration.
Test Cases:
71
Jack Cooke A Level Computer Science Project
test_eval_board_empty:
Description: Verify that an empty board returns a score of 0.
Expected outcome: An empty board should have a score of 0.
72
Jack Cooke A Level Computer Science Project
test_eval_board_standard:
Description: Verify that the standard starting position returns a score of 0.
Expected outcome: A symmetrical board should return a score of 0.
73
Jack Cooke A Level Computer Science Project
test_eval_board_all_white:
Description: Verify that a board with all white pieces returns the correct score.
Expected outcome: An all-white board with a default setup should have a score of
226.0 when using the NEGAMAX evaluation framework
74
Jack Cooke A Level Computer Science Project
test_eval_board_mixed:
Description: Verify that a board with mixed pieces returns the correct score.
Expected outcome: A board with a known random mix of pieces, where the value
of each piece is the same, and the team is different, should return a value of 0
using the NEGAMAX evaluation framework.
75
Jack Cooke A Level Computer Science Project
test_eval_board_normalised:
Description: Verify that the board score is normalised correctly.
Expected outcome: All normalised scores should be the datatype float between 0
and 1.
76
Jack Cooke A Level Computer Science Project
See 1:41 - 2:25 in the attached video and 4:41 - 5:12 for demonstration.
Test Cases:
test_node_initialization:
Description: Verify that nodes are initialised correctly.
Expected outcome: The initial node values are as expected
77
Jack Cooke A Level Computer Science Project
test_node_is_leaf:
Description: Verify that the leaf status of a node is determined correctly
Expected outcome: A node with no children should be classed as a leaf; a node
with any number of children should not be considered a leaf.
test_node_expand:
Description: Verify that nodes can be expanded with valid moves.
Expected outcome: A node with a valid move can be expanded into multiple
children, each with a different board state.
78
Jack Cooke A Level Computer Science Project
test_node_apply_move:
Description: Verify that a move can be applied to a node.
Expected outcome: A node with a move applied to it has an array where the new
move is present.
test_node_update:
Description: Verify that nodes can be updated with a value.
Expected outcome: When the update method is called on a node, the number of
visits increments and the value changes.
79
Jack Cooke A Level Computer Science Project
test_mcts_select:
Description: Verify that the MCTS algorithm selects the correct node.
Expected outcome: A root node is selected correctly.
test_mcts_expand:
Description: Verify that the MCTS algorithm expands the correct node.
Expected outcome: An expanded node has more than 0 children.
test_mcts_simulate:
Description: Verify that the MCTS algorithm simulates a game correctly.
Expected outcome: A node that has simulated called has a float value associated.
80
Jack Cooke A Level Computer Science Project
test_mcts_backpropagate:
Description: Verify that the MCTS algorithm backpropagates the value correctly.
Expected outcome: The number of visits and value changes when the
backpropagate function is called.
test_mcts_run:
Description: Verify that the MCTS algorithm runs correctly.
Expected outcome: When the run function is called, the root node has been
visited at least once.
81
Jack Cooke A Level Computer Science Project
test_mcts_best_move:
Description: Verify that the MCTS algorithm selects the best move
Expected outcome: When running MCTS the best move is always associated with
a node.
82
Jack Cooke A Level Computer Science Project
GUI Tests
Purpose: Verify the functionality of the graphical user interface. Test Data: User
inputs and board configurations. Expected Outcome: The GUI updates correctly
based on user interactions.
See 2:25 - 2:48 in the attached video and 4:41 - 5:12 for demonstration.
Test Cases:
test_initialization:
Description: Verify that the GUI components are initialised correctly.
Expected outcome: When creating a GUI, the correct widgets are present.
83
Jack Cooke A Level Computer Science Project
84
Jack Cooke A Level Computer Science Project
test_login_valid:
Description: Verify that a valid login works correctly.
Expected outcome: When logging in with the correct credentials, a user is logged
in and the window changes.
test_login_invalid:
Description: Verify that invalid logins are handled correctly.
Expected outcome: When logging in with the incorrect credentials, a user is not
logged in, and the login window does not change.
85
Jack Cooke A Level Computer Science Project
test_ui_updates_on_move:
Description: Verify that the UI updates correctly when a move is made.
Expected outcome: After a move is made, the UI move count and player to move
should change.
test_parse_ini:
Description: Check that .INI files are correctly loaded.
Expected outcome: A known dummy INI file should be loaded correctly into a
dictionary.
86
Jack Cooke A Level Computer Science Project
See 3:16 - 3:55 in the attached video and 4:41 - 5:12 for demonstration.
Test Cases:
test_initial_setup:
Description: Verify that the initial setup of the chessboard is correct.
Expected outcome: The positions of each piece are correct for a standard chess
game.
87
Jack Cooke A Level Computer Science Project
test_load_openings:
Description: Verify that the openings are loaded correctly.
Expected outcome: The openings are loaded correctly into a non-empty
dictionary.
test_get_opening:
Description: Verify that the correct opening is identified.
Expected outcome: A non-standard opening is classed as unknown.
test_get_all_valid_moves:
Description: Verify that all valid moves are returned correctly.
Expected outcome: A standard chessboard should have multiple valid moves.
88
Jack Cooke A Level Computer Science Project
test_board_array_to_fen:
Description: Verify that the board array is converted to FEN correctly.
Expected outcome: Any chess board should return a valid non-0 length string in
Forth Edwards Notation.
test_get_material_count:
Description: Verify that the material count is calculated correctly.
Expected outcome: Any chessboard should have a positive integer material count.
test_move_piece:
Description: Verify that pieces can be moved correctly.
Expected outcome: Valid moves should be accepted, and invalid moves should be
rejected.
89
Jack Cooke A Level Computer Science Project
test_enpesaunt:
Description: Verify that en passant moves are handled correctly.
Expected outcome: A board not set up for en passant should return False.
test_castling:
Description: Verify that castling moves are handled correctly.
Expected outcome: A board set up for queenside castling should allow castling.
test_are_you_in_check:
Description: Verify that the check status is determined correctly.
Expected outcome: A board with position where the user is not in check returns 0.
90
Jack Cooke A Level Computer Science Project
test_game_over:
Description: Verify that the game-over status is determined correctly.
Expected outcome: A board where there is no checkmate is not over.
test_pawn_promotion:
Description: Verify that pawn promotion is handled correctly.
Expected outcome: A pawn can be promoted to a queen when on a valid square.
91
Jack Cooke A Level Computer Science Project
Networking Tests
Purpose: Verify that the client and server interact as expected. Test Data: Various
standard application operations, login, and moves. Expected Outcome: The
networked client behaves like the local GUI client.
Test Cases:
Client:
test_recieve_data:
Description: Verify that data can be sent from the server to the client
Expected outcome: A socket allows the client to send and receive data and
serialise Python objects using pickle.
92
Jack Cooke A Level Computer Science Project
Server:
test_chess_server_init:
Description: Checks initialisation of the server
Expected outcome: A server binds to the correct ports and creates threads to
handle each connection.
93
Jack Cooke A Level Computer Science Project
GUI:
test_ui_initialization:
Description: Check that the correct layout and labels are set.
Expected outcome: The layout of the board is set correctly.
test_login_ui_initialisation:
Description: Check that the username and password fields are present.
Expected outcome: The login UI has the correct field to authenticate.
94
Jack Cooke A Level Computer Science Project
test_handle_login_sucess:
Description: Checks that the test_user can log in.
Expected outcome: A user with the correct credentials is able to authenticate and
change the window.
test_handle_login_faliure:
Description: Checks that a user without an account is unable to log in
Expected outcome: A user with the wrong credentials is unable to log into the
system.
95
Jack Cooke A Level Computer Science Project
test_update_clock:
Description: Checks that the clock inside the UI updates relative to the current
time
Expected outcome: The clock widget updates to the correct value.
test_handle_click:
Description: Checks that pieces can be moved
Expected outcome: When a user clicks on a square for a piece to be moved to, the
correct functions are called in the background
Execution Plan:
The tests will be executed in multiple environments using tox for orchestration,
pytest, and unittest for testing. The results will be analysed using SonarQube to
ensure code quality and coverage.
96
Jack Cooke A Level Computer Science Project
Evaluation
97
Jack Cooke A Level Computer Science Project
98
Jack Cooke A Level Computer Science Project
● Develop mobile versions of the chess app to expand its accessibility and
reach a broader audience.
99
Jack Cooke A Level Computer Science Project
100
Jack Cooke A Level Computer Science Project
101
Jack Cooke A Level Computer Science Project
Objective: The system must be able to store relevant details about the current
board position.
Implementation Details:
● Board Representation: The ChessBoard class in chess_board_1.py maintains the
board's current state, including the position of all pieces.
● Checkmate and Stalemate: Implemented inside the same function, returning different
values based on the status
102
Jack Cooke A Level Computer Science Project
103
Jack Cooke A Level Computer Science Project
Objective: The user must be able to view previous games and the move order.
Implementation Details:
● Game Records: Game data is saved to a SQLite Database
Customisation
Objective: The user should be able to change piece icons & board
colours.
Implementation Details:
● The user can change the icons by replacing the SVG files in ./media/white or
./media/black
● The user can change the board colours by modifying them in gui.py
AI Player
Objective: The user should be able to play against a chess bot with
adaptive difficulty.
Implementation Details:
● Existing AI: The AI uses a Monte Carlo Tree Search algorithm to play against the
user.
104
Jack Cooke A Level Computer Science Project
Key Resources
https://www.chessprogramming.org/Main_Page
https://www.chess.com/terms/chess-pgn
https://www.chess.com/terms/fen-chess
https://www.pythonguis.com/tutorials/creating-multiple-windows/
https://towardsdatascience.com/train-your-own-chess-ai-66b9ca8d71e4
https://database.lichess.org/#standard_games
https://www.kaggle.com/datasets/datasnaek/chess/data
https://github.com/Lightning-AI/pytorch-lightning
https://en.wikipedia.org/wiki/Minimax
https://www.freecodecamp.org/news/create-a-self-playing-ai-chess-engine-from-s
cratch/#part-3-how-to-train-the-ai-model
https://pytorch.org/
https://docs.python.org/3/howto/logging.html
https://doc.qt.io/qtforpython-5/PySide2/QtWidgets/QPushButton.html#more
105
Jack Cooke A Level Computer Science Project
Build Log
Features
PR #1 431f327:
- SQLite wrapper allowing basic CRUD operations
- DB create containing schema
- Test coverage for non-PyQt5 functions
106
Jack Cooke A Level Computer Science Project
- Fixed by splitting the shard into multiple files and loading them
asynchronous at a rate determined by the system the program is running
on
Commit ee407f3: fix tensor structure, auto remove old logs, configure
tb logging
- Issue: The old structure did not include multithreading, causing subpar
training speeds.
- Fixed by specifying the number of workers in a pool and restructuring the
tensors to store game data more efficiently, mapping the data to 32-bit
floating point values
107
Jack Cooke A Level Computer Science Project
Bug Fixes
More Features
Features:
108
Jack Cooke A Level Computer Science Project
PR #28 Documentation
- Update install process and supported Python versions
109
Jack Cooke A Level Computer Science Project
References
Works Cited
26 November 2024.
https://en.wikipedia.org/wiki/Monte_Carlo_tree_search. Accessed 26
November 2024.
https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.p
110