Skip to content
This repository has been archived by the owner on Dec 26, 2021. It is now read-only.

Project Report

au2001 edited this page Nov 15, 2018 · 1 revision

Efrei Paris

Python: Mastermind Project Report

November 15t​h​, 2018
Group I
GARNIER Aurélien
CALLOT Valérian

Table of Contents

Part Page
Introduction Page 1
Project Overview Page 1
Original Ideas Page 2
Explaining a Few Advanced Features Page 2
Organization & Project Management Page 3
The Difficulties We Encountered Page 3
What About The Future? Page 4

Introduction

During this first semester, we were tasked to create a ​Mastermind game using the Python programming language. Mastermind is a famous board game where a player, the ​codebreaker​​, tries to ​guess a 4-color code generated by another player, the codemaker​​, in a limited number of attempts. To modernize this ancient board game and to refine it, we also incorporated ​additional features​​.

Project Overview

Our Mastermind consists of ​three game modes​​. The first one is a regular ​Singleplayer​​, where the user plays as the codebreaker, against the computer, which is the codemaker and generates a random code for each game.
The second game mode is an ​online game mode, in which the user plays as the codebreaker against a computer, once again, but this computer can be a remote server. This way, the user can not cheat by accessing the code, thus a reliable scoreboard can be held.
The third game mode is a ​computer versus computer game mode where an “artificial intelligence” (AI) tries to crack a code generated at random. This AI solves a classic Mastermind in an average of about ​4.636 turns (computed on 5 million games with codes generated uniformly).

The program starts with a ​menu allowing the user to select the game mode he wish to start. In this same menu, the user can also ​edit 3 parameters​​: the code’s length, the number of available colors for each element of the code, and the maximum number of attempts the user has to guess the code.

Other improvements were made such as true colors in the command line interface (CLI) compatible with *nix systems, or saving and restoring a game (see below).

Original Ideas

We added several unique features to make the program stand out and have a more thorough user experience and allow a diversified gameplay.
For example, one of these features is a ​token system​​, generating a compact string every time a game is interrupted. This token allows the user to ​resume the game whenever he wants, and works across the three available game modes.
Furthermore, a token can be ​sent to another user and is sufficient to resume the game from where it was interrupted, provided the other user also has this Mastermind program installed, and with the exception of the online game mode where the code and score are not guaranteed to be transferred over, to prevent abuse and cheating.

Several ​easter eggs have also been implemented, adding fun references to internet culture for people who like fiddling around...
For example, if you try to use the ​Konami Code in a singleplayer game (a sequence consisting of the arrow keys up, up, down, down, left, left, right, right followed by the keys B and A), ​the computer will help you by giving you the real code instantly, just like the Gradius game released by Konami in 1986 gave you 99 lives, originally used for debugging purposes​​ but accidentally left in the final release of the game.

Explaining a Few Advanced Features

For further information on the online game mode’s inner workings, see the annexed MasterMind Project Protocol specification​​, which details the protocol used for communicated between the client and the server while in the online game mode.

Organization & Project Management

At first, we each worked on our side on the ​skeleton​​ of the project in order to have our own approach. Then, we shared our progress to obtain a ​solid foundation​​ on which we could develop the rest of our work.
Rather than working step by step, we designed from the start an ​expandable program allowing us to easily add the features we had planned, with the most important modules already integrated, and the functions that were going to be the most useful throughout our progress already created.

The bulk of the project was ​discussing the elements to implement​​ and the details of how they should be coded, while keeping in mind the program’s ​efficiency yet simplicity and practicality​​.
Valérian worked on creating several individual features while Aurélien mainly put the pieces together while sharing his experience with more advanced features, also supervising and helping optimize different parts of the project.

The Difficulties We Encountered

One of the issues we encountered during this project was when designing the communication between the client and the server at the packet level.
Because of a bug in the function reading and parsing the packets, the headers and footers of the packet did not synchronize correctly with the read operations, preventing a valid connection to be detected and thus established between the server’s device and the client. It was quite an issue because it blocked the testing of the online mode.
Fortunately, we managed to solve it rather quickly and the online mode began working correctly.

Some other of the difficulties came from Valérian's weaker experience in programming and knowledge of modules. For each unknown package, Aurélien explained the usage and purpose, and then Valérian conducted further research to better understand their functioning. This project also allowed us to learned how to manipulate bytes more easily and to use the curses module, which also had to be installed and debugged on Windows to test the program during its creation.

What About The Future?

Having a restricted time frame, we could not implement all the features we thought of. Indeed, the program is not perfect and we could add many new components.

For example, a possible improvement for our Mastermind would be to create a Graphical User Interface using modules such as Tkinter or pygame to allow to finalize the project both at the user and cosmetic level, and so to possibly distribute it.

In the aim of implementing ​local multiplayer​​, it would be possible to create new game mode, for example tournaments and rotating players.

The ​tournament game mode would make players fight against each other in ​brackets​​, each duel consisting of two rounds where each player acts once as the codemaker and once as the codebreaker, in the ​classic Mastermind board game. The winner is then the one who wins the final duel between the two finalists. This game mode could either be created on a ​single machine​​, one match at a time, or could be setup to work with several ones on a ​Local Area Network​​.

The ​rotating players game mode​​, consists of ​one codemaker​​, the computer, and several codebreakers playing in parallel and all trying to guess the same code. They each know the progress of the other players, but do not have access to the exact colors they tried, thus pushing players to ​improve their strategy to be the first among all the players to find the code.