Mastermind Project
Mastermind Project
0 library
1. Mastermind Game
Mastermind is a puzzle game where the goal is to guess a secret combination of colors. One player
chooses the combination and the other tries to guess it.
At the top, there are four boxes with question marks which represent the secret combination to be
guessed. They will remain hidden until the correct combination is found or the game is over.
Just below there is a large table divided into rows. Each line represents an attempt by the player to
guess the color combination.
At the very bottom of the interface there are four colors, the player clicks an infinite number of times
until he likes the color of a button and then validates the color combination
Command Buttons:
Mode: Can be used to change the game mode (for example, from easy to hard mode).
Choice of Combination:
At the start of the game, the secret combination is chosen automatically by the computer or another
player, and hidden in boxes at the top with question marks.
Attempt to Guess:
The player chooses colors by clicking on the colored circles at the bottom and places them in the
squares of a row on the board. The active line is usually the bottom one that is not yet in use.
Once the player is satisfied with their color selection, they click "Validate". The game then checks the
attempt:
For each color correctly placed in the right position, a specific indicator (often a small black pawn) is
placed on the left (if two buttons are correctly placed then the rectangular pawns on the right turn
black after the user clicks on validate)
For each correct but incorrectly positioned color, a different indicator (often a small white pawn) can
be used and displayed on the right on the rectangles after the user has clicked on "validate"
If the user chooses a combination with four colors but the secret combination has none of these colors
then the rectangle pawns to the right of the interface do not change color.
If the user has two good colors which are well placed on the four, two rectangle pawns on the right
become black. If it has a good color, for example one of the pawns on the right is white. He may also
have made a combination having 4 colors including 3 good and two well placed then the rectangular
pawns on the right 1 is white and 3 are black. The player wins the game if his four pawns are correctly
placed, therefore after validation, the rectangles on the right are black
End of Game :The player continues to fill in the lines until the secret combination is correctly guessed
or until all lines are filled, indicating a loss. If the combination is guessed correctly, the secret colors
are revealed.
2. GUI
We must create a modern and ergonomic graphical interface to facilitate the user experience. The
graphic interface for the moment is blank, that is to say without background color, shape of buttons
etc... subsequently we will use the 'design.css' file in order to make modifications on the main board
of the game. The goal is to provide something pleasant and modern for the user to look at.
The buttons “combi” have to be rounded, we have to add some color to the rectangle buttons (dark
and white it’s depending on the combination of the user). The design seems to our we have to enhance
our !
3. Programming
Above we have the main window which corresponds to the game board. On the left we have the
buttons to interact during a game. The board is made up of two buttons organized in two separate
columns: the “ind” buttons located on the left (those that the user can press and change the color)
and the “ind” buttons on the right which will serve as an indication for the player (disabled button that
cannot be pressed or clicked by the player).
Basically as explained previously, the mastermind game consists of guessing the color combination
chosen randomly by the computer. The user has 12 tries (the last line at the top has question marks
"?" because it is the mystery combination randomly generated by the computer, the buttons in this
line cannot be clicked or pressed by the player, at the end of the game, the buttons of this last
combination are revealed: they correspond to the mystery combination, if the player wins their color
is also revealed at the end of the game). With each click, the “combi” buttons change color
independently of each other. The user enters the combination he thinks is correct and presses the
“validate” button to move on to the next one.
It allows you to replay a game and therefore restart it, be careful the player can only replay if he has
lost or abandoned the current game otherwise it is impossible to replay (we can create a dialog window
to inform him that it is possible to play again only if he has finished the game or if he abandons it). I
think we must first build refresh etc functions that we will call to replay, obviously as soon as the user
clicks on the "replay" button, we will display a dialog box to ask him if he really wants to replay but as
explained previously this box will only be displayed if he has won or abandoned the game
This button already works, I have configured it, it just opens an additional window with a background
image which writes the rules of the game. However I would like you to ensure that the button is clicked
once at a time for example in my case if I click on “rules” several times, several windows are displayed
and that is not the goal. I want a window with the rules even if the button is pressed several times in
a row.
The purpose of this button is to validate the combination of the current trial that the player is carrying
out. Let me explain: upon launching the game, the player can only click on the four “combi” buttons
located at the bottom of the screen and change their color with each click. However, he must validate
whether his suit is safe to see if it is good and move on to the next one or not. The purpose of this
button is to freeze/deactivate the buttons of the combination of the current test (by letting their color
appear, basically you have to deactivate them so that the user can no longer click on them) and activate
the buttons above the next test. In our case the user first enters the combination of test no. NB_ESSAIS
= 12 and the next corresponds to NB_ESSAIS – 1 = test number 11 and so on until test no. 1. The
“validate” button is initially deactivated and it is activated when at least each “combi” button (there
are 4 per line) of the current test has been pressed/clicked at least once (roughly that it has a color).
The purpose of this button is to allow the player to abandon the game if they wish. I started to
configure this function but it does not work. The idea is to create a dialog box with the words “do you
want to give up” and two buttons as a choice: “yes” and “no”. If the player clicks on “yes” then the
dialog box closes, the secret combination is revealed and all the buttons on the board (the combi
buttons) are frozen. If he clicks on “no” then the dialog box closes and the game resumes. Again we
will have to call on functions that we will have to create
This button allows you to choose the game mode for the moment when you click on it you have a very
small and horrible dialog with two modes: mode 1 which consists of playing as a player and mode 2 as
a user I explain myself. If you look closely at my code in the files "mastermind. c/. h" "combination. c/.
h" or "test_essais. c/. h» you will see that I programmed two kinds of possible game the first mode
traditionally consists of playing and trying to guess the randomly generated combination by the
computer at the beginning of the game and the second allows you to choose the combination and that
the computer guess your secret combination (will do the first test automatically and as soon as
“validate” is pressed, will add a new combination automatically.
Warnings
Only files design.css vue. h vue. c main. c, common.hcontroleur. h et controleur. c (and potentially
other additional files you want to create that you will need) must be modified, forbidden to touch the
rest of the files!!
I obviously report the functions and actions on the buttons I wanted for the smooth running of the
game and a game but obviously that it will be necessary according to your needs to create additional
functions like refresh, 'score' to change the score of the player (calculated as you wish), you will have
to split the init_vue function into several functions to do something cleaner, for the abort function it
will surely be necessary to use the disable all function and adjust it or create other functions as a
function to reveal the mystery combination, a function to know in which mode the player is and we
will initialize the mode where the player guesses by default the combination and so on. For the
graphical interface I want all the buttons combis are round, buttons slightly rounded and a blue
background sky, it should be harmonious. I also want to have background music and noise when you
click on the validate button for example. Think about it all and good luck!