Project Pseudocode

The Mastermind Game

Step 1 Generation of a 4-digit number with each digit different from the others

Step 1.1 Generate a random number (0 <= number < 10000)

Step 1.2 Convert the generated number into a numeric string

Step 1.3 Check all digits of the number to see if each digit is different from the others

Step 1.3.1 go back to step 1.1 until the condition is satisfied

Step 1.4 Use ‘length’ function to check the number of digits of the generated number

Step 1.4.1 If necessary add ‘0’ before the number until it is a four digit one

Step 2 The process of the game

Step 2.1 Allow the user to input a four digit number

Step 2.1.1 Use ‘length’ function to check the number of digits of the input number

and go back to Step 2.1 until the condition is satisfied

Step 2.1.2 Check all digits of the number to see if each digit is different from the

others and go back to Step 2.1 until the condition is satisfied

Step 2.2 Compare the input number with the generated number and give signals

Step 2.2.1 Using nested for loop, compare each digit of the input number with

each digit of the generated number

Step 2.2.2 Store the output signals. Award a ‘*’ for both correct digit and location,

award a ‘#’ for correct digit only

Step 2.3 Indicates the end point of game

Step 2.3.1 Output the signals together with the input number

Step 2.3.2 Check if the player has already worked out the answer or not, if yes,

give a ‘Congratulations’ message and end the game. Otherwise,

continue the game until the player wins or the number of guesses

reaches 10

Step 3 To start a game for the 2nd time or quit the game

Step 3.1 Receive response from the player, either yes(Y) or no(N)

Step 3.1.1 If the response is in lowercase letter, convert it into uppercase one

Step 3.2 Continue the game if the response is yes(Y), quit the game if the response is no(N)