You are on page 1of 8

Fin Brickman

Analysis

Background

The aim for the project is to provide a resource for maths teachers do a game theory project with
their students. Despite game theory not currently being on the national syllabus in the UK, this
system would fill a need for a longer-term project to stretch more able students to improve their
problem-solving skills. The system would specifically be using the game Nim. There are many
variations of this, but for the purposes of this system there are multiple groups of stones, and on
one’s turn one can take 1, 2 or 3 stones from a single pile, and whoever takes the last stone wins.
The number of stones in each group would be variable and the students would be able to play either
against each other on different computers on the same local network, or against perfect AI, or watch
AI vs AI, with the purpose being for them to attempt to understand how the strategies work. The
system will allow teachers and students to register separately, with students tied to a specific class
or teacher. Their details will be stored in a database which will be checked for correct username and
password whenever they log in. On entry to the website there is a welcome page showing global
and class leaderboards, a game history for that specific user, and all other logged in users for their
class. They then have the option to either play with another logged in user in their class, to play
against the AI, or to watch AI vs AI, to understand how the strategies work. At the end of the game
the program will display a win screen or loss screen with an animated change of rating for students
to be able to track their progress. Users can then return to the home page or log out. Teachers can
log in and see their class leaderboard and see which students have beaten the perfect AI for each
number of stones, so that they can tailor their lessons towards learning strategies for certain number
of stones or helping specific students who are struggling. My end user is Neil Pickup, a Maths
teacher at the Dragon School, Oxford, who often uses long term projects for his abler students,
especially in a post scholarship exam group at the end of Year 8 where there is more opportunity for
extension.

The user will need no advanced IT skills, just ability to run the Python file. The web interface will
be user friendly. They will need Python3 with the following modules installed:

 Flask
 Flask_WTF
 WTForms
 Flask_SocketIO
 SQLite3

Interview with Neil Pickup

Recorded as a Zoom interview on the 29th September 2021

Can you give me your job description?

Head and teacher of Maths at the Dragon School, Oxford

What do you currently do to stretch your students?


Fin Brickman

I encourage them to try and think critically and reverse engineer problems, going beyond the
curriculum to learn new areas of Mathematics.

Who would use the system?

I tend to use longer term projects for all of my classes but the system would especially be for
intelligent Year 8 students post-scholarship exams in order to stretch and challenge them before
their move to their next school. In the past I have done some game theory projects with them
including games such as the Prisoner’s Dilemma. Ideally the system would be formatted so that
parameters can get more advanced and the strategies more involved over a number of lessons.

What features would you like the system to have?

In the past with game theory projects, the most important thing for me has been the ability to log in
as a teacher to view my students’ progress and see how their strategies change over the course of a
number of lessons. In the case of your project, this could be seeing students’ rankings and who has
beaten the perfect AI.

What levels/features of AI would you want?

A perfect AI would be very useful for the students to be able to see what strategies to use and how
to adapt that to a different number of stones. Ability to watch perfect AI vs perfect AI would also be
helpful for them to see whether the first or second player has the advantage with a given number of
stones. I think easier AI which remove stones at random or deliberately choose worse moves could
confuse students if they are trying to understand the best way to play the game, as it makes no sense
for the AI not to do the obvious move in certain situations.

How could it be made more interesting for the students?

A hint button could be useful once per game to help them if they’re feeling stuck and frustrated. I
would also want them to be able to compete against one another and track their progress.

Summary of discoveries from the interview

• Teacher accounts which can view student progress


• Changeable parameters to provide engagement over a longer period of time]
• Other AI levels are not necessarily important as the AI doing random, bad moves isn’t that
helpful for students understanding how to play the game
• Ability to watch perfect AI vs AI would help students understand strategies
• A hint button once per game with the perfect move would help to engage students
• A perfect AI should be easy enough to understand for a Year 8 student so that they can use it
themselves, especially for a small number of stones

Modelling the current system


Fin Brickman

One example of a Nim game online is https://www.transum.org/Software/Nim/. This website is


fairly basic in functionality with the user forced to go first, and no ability to log in to track progress.
This website user a slightly different variant of Nim, with the user allowed to take any number of
sticks as long as they are from the same pile. The system does not store user information. The IPSO
diagram for this is shown below:

IPSO Information

Input Button Click to remove sticks


Button Click to choose level
Button Click to ask computer to play

Process Calculate correct move to play

Store None

Output Removing stick removed by user


Removing stick removed by AI
Showing win screen or loss screen as
appropriate

The primary problem with this system is that there is no ability to log in. This in turn means that
there is no ability to track your progress, no ability to play online against other players, and teachers
cannot log in to track their students’ progress. Furthermore, there’s no ability to choose to go first or
second against the AI, so it is more difficult to understand the way to beat the game.

The flowchart for how the website processes the game is shown below:
Fin Brickman

Consideration of possible solutions to the problem

The program will be in Python 3 in order to facilitate use of Flask and SQLite3 modules and will be
coded in Visual Studio Code.

Top Level Objectives

Objective Performance Criteria


Allow user to register If the details are valid, they should be uploaded
to the database, and otherwise, appropriate
error messages should be shown.

Allow user to log in Welcome page is displayed if details are correct


and otherwise appropriate error messages are
displayed
Fin Brickman
Display welcome page When the user has logged in, they should be
able to see:
 Class leaderboard with their
whole class’ rankings
 Global leaderboard with top 10
global rankings

Ability to choose parameters to enter game Dropdown menus for:


 Stones in each pile
 First player (self or AI)
 Second player (self or
AI)
The game screen is then displayed as
appropriate given these parameters
Allow user to play the game When the user clicks the buttons to remove
stones they are removed on both user and
opponent’s screens. When no stones are left,
the game ends
Process the result Animate any rating changes and store results in
database
Display different teacher account welcome Show student rankings, leaderboard, and which
page students have beaten the perfect AI for which
number of stones
Allow user to log out When the user logs out they are removed from
the list of logged in users and are taken to the
log in page

Objectives List

1. Ability to register
1.1 Choice between registering as student or teacher
1.2 Validation of email addresses
1.3 Verification of password
Fin Brickman
1.4 Checking uniqueness of email addresses
1.5 Checking uniqueness of username
1.6 Checking username is not too long
1.7 Checking that username field is not empty
1.8 Checking that name is not too long
1.9 Checking that name field is not empty
1.10 Ability for teacher to choose institution code
1.11 Checking that institution code is unique
1.12 Checking that institution code is not empty
1.13 Checking that institution code entered by student matches current institution code
1.14 Appropriate error message displayed
1.15 Clear form if an error is present
1.16 Database is updated with new teachers and students
1.17 Passwords are hashed when inserted into database

2. Ability to log in
2.1 Error message if username/password are incorrect
2.2 Form is cleared if error message is displayed
2.3 If the correct username and password are entered, the user is added to the list of logged
in users
2.4 If username and password are correct the welcome page is displayed

3. Welcome page displayed


3.1 All logged in students in your class are visible to you on the welcome page after logging
in
3.2 Number of player vs player wins displayed
3.3 Number of player vs player losses displayed
3.4 Number of player vs AI wins displayed
3.5 Number of player vs AI losses displayed
3.6 Last 10 games displayed with opponent and result
3.7 Worldwide leaderboard of top 10 players visible
3.8 Whole class leaderboard of names visible
Fin Brickman
3.9 Ratings displayed next to names in worldwide leaderboard
3.10 Ratings displayed next to names in class leaderboard

4. Ability to enter game


4.1 Dropdown menu displayed for number of stones in each pile
4.2 Dropdown menu displayed for first player
4.3 Dropdown menu displayed for second player
4.4 Ability to choose number of stones in each pile
4.5 Ability to invite other logged in student in your class to game with choice of first and
second player
4.6 Ability to play against perfect AI as either first or second player
4.7 Ability to watch perfect AI vs perfect AI

5. Playing the game


5.1 Ability to remove stones with buttons
5.2 Ability to get a hint with perfect move once per game
5.3 Buttons are removed when that move is no longer valid

6. Processing result
6.1 The winner gets a win screen
6.2 The win screen animates rating increase for player vs player
6.3 The loser gets a loss screen
6.4 The loss screen animates rating decrease for player vs player
6.5 Statistics table is updated in database
6.6 Button to return to home screen or to log out are displayed

7. Teacher account welcome page


7.1 Ability to see student rankings
7.2 Ability to see which students have beaten perfect AI for which number of stones
7.3 Ability to see class leaderboard
Fin Brickman

8. Ability to log out


8.1 When user clicks log out button, they are removed from the list of logged on users
8.2 User is returned to log in page

You might also like