This repository contains the C++ source code and built binaries of the logical game called Mastermind. The project uses Qt Open Source libraries. For coding I used Qt Creator as IDE. It was built with MinGW on Windows 10 x64.
You can download the built binaries in the release section of the repository. It can be run on Windows 10 by PCs having x64 architecture processor. Download release
There are two players: the codemaker (computer) and the codebraker (You). The codemaker creates a code and the codebreaker’s aim is to find out this code.
The screen is devided into three main parts: the codemaker’s code, the codebreaker’s guesses (decoding table) and the feedbacks from the codemaker according to the guesses.
The codemaker chooses four colors out of six (blue, red, yellow, green, pink and brown), and decides the position of these four colors from 1st to 4th. This will be the code, which the codebreaker must find out.
You do not see the codemakers code, since it is shown grey in the codemaker’s section. You must guess four colors and the position of these colors in the decoding table. When done, press next step.
In the next step you will see a feedback in form of black and white marks on the right side of your previous guess. The marks inform you how close your guess was to the codemaker’s code. Black marks show how many of your guesses were right color and position at the same time. White marks show how many of your guesses were right color, but wrong position. Empty marks show how many of your guesses were not right at all. You can use this feedback to adjust your guess in the next step.
One simple example: if the code is 1st:red, 2nd: blue, 3rd:yelow, 4th:pink and your guess is 1st:blue, 2nd: red, 3rd:brown, 4th:pink, then the marks are white, white, black, empty.
The colors can be duplicated e.g. 1st:red, 2nd: red, 3rd:blue, 4th:blue. If your guess was 1st:red, 2nd:red, 3rd:red, 4th:yellow, the marks would be black, black, empty, empty. Two right colors are rewarded only twice.
There are no blank positions (positions without color).
You have 12 chances to guess the right colors and positions. 12 steps to brake the code. The sooner, the better.
If you can find out all the colors and their position in not more than 12 steps, you win. If not, you can try it again. The code is generated by computer randomly.
The latest five codebreaks done in the least steps are stored in the hall of fame table with the player’s name.
Good luck, Codebreaker!
further info: Wikipedia Page
- to show player's name during code breaking
- to create a message box when game won and exit to main menu
- to modify hall of fame table with scores and names