Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

need help writing a C program for the game of mastermind, using numbers instead of colours sample: execution: In the simple, text-version of Mastermind game

need help writing a C program for the game of mastermind, using numbers instead of colours

image text in transcribed

sample: execution:

image text in transcribed

In the simple, text-version of Mastermind game that we are going to develop, instead of colors we simply use digits 1 to 9. Therefore, codemaker (Computer) will randomly selects four unique, non- duplicated, digits and then codebreaker will start guessing the four digits. If the codebreaker guesses the correct code in less then or equal to ten guesses, s/he wins and otherwise loses. Then, the codebreaker has the opportunity to play again or just exit from the game. In each step of the game, proper message should be provided by the codemake (computer) to the codebreaker. For instance, at the beginning there would be a welcome message, followed by asking the codebreaker to guess the code. After each guess, an accurate feedback should be shown to the codebreaker. If codebreaker wins/loses, proper message showed be shown to the codebreaker as well. You can get some ideas from the sample execution of the program on page 4 of this document. Part B: Pseudocode: (40 marks) Using the above game rules, write the pseudocode (formal or informal) for the Mastermind game. As a hint, we start it as follows, and you should complete it: 1. Start 2. Show a Welcome message to the player. 3. Generate a random code. 4. ... Complete the next steps X. Ask the player if they want to play again or not a. If yes, go to step 3 b. If no, show a Goodbye message and end the program X+1. End Part C: Flowchart (40 marks) Using the pseudocode you wrote in the previous part, draw a flowchart for the Mastermind game. You can use any flowchart software, like Raptor, or simply draw it on any software with graphical capabilities, like Word, Excel, PowerPoint, Paintbrush, etc. Terminal src (Saeeds-MacBook Pro local) X bash-3.2$ /MasterMind Welcome to MasterMind Game !!! Version 4 Release Date: Jan. 10, 2020 Programmer: Saeed Samet. You have 10 remaining chance(s). Guess 4 numbers (enter @ to exit): 1 2 3 4 Correct Location & Number : Correct Number : 2 You have 9 remaining chance(s). Guess 4 numbers (enter @ to exit): 5 126 Correct Location & Number 10, Correct Number : 1 You have remaining chance(s). Guess 4 numbers (enter @to exit): 7 3 4 6 Correct Location & Number : Correct Number : 4 You have 7 remaining chance(s). Guess 4 numbers (enter @ to exit): 2 4 6 7 Correct Location & Number: 1. Correct Number: 3 You have 6 remaining chance(s). Guess 4 numbers (enter @ to exit): 6 4 7 3 Correct Location & Number : 4, Correct Number : @ Excellent!!! you solved it with 5 guesses, in 96 seconds. Do you want to play another game? (No:0, Yes: 1)1 You have 10 remaining chance(s). Guess 4 numbers (enter to exit): 1 1 1 1 Correct Location & Number : @, Correct Number : @ You have 9 remaining chance(s). Guess 4 numbers (enter to exit): 2 2 2 2 Correct Location & Number: 0, Correct Number: 0 You have 8 remaining chance(s). Guess 4 numbers (enter @ to exit): 3 3 3 3 Correct Location & Number : 0, Correct Number : You have 7 remaining chance(s). Guess 4 numbers (enter to exit): 4 4 4 4 Correct Location & Number: 0, Correct Number : You have 6 remaining chance(s). Guess 4 numbers (enter @ to exit): 5 5 5 5 Correct Location & Number: 1, Correct Number: 0 You have 5 remaining chance(s). Guess 4 numbers (enter to exit): 6 6 6 6 Correct Location & Number : 1, Correct Number : You have 4 remaining chance(s). Guess 4 numbers (enter @ to exit): 7 7 7 7 Correct Location & Number : 1, Correct Number : You have 3 remaining chance(s). Guess 4 numbers (enter @ to exit): 8 8 8 8 Correct Location & Number : 1, Correct Number : You have 2 remaining chance(s). Guess 4 numbers (enter o to exit): 5 Correct Location & Number : 2, Correct Number : 2 You have 1 remaining chance(s). Guess 4 numbers (enter @ to exit): 5 6 8 7 Correct Location & Number : 1, Correct Number : 3 Sorry, You Lost : Answer is:7 6 5 8 Do you want to play another game? (No:0, Yes: 1) bash-3.2$ 1 6 7 8 In the simple, text-version of Mastermind game that we are going to develop, instead of colors we simply use digits 1 to 9. Therefore, codemaker (Computer) will randomly selects four unique, non- duplicated, digits and then codebreaker will start guessing the four digits. If the codebreaker guesses the correct code in less then or equal to ten guesses, s/he wins and otherwise loses. Then, the codebreaker has the opportunity to play again or just exit from the game. In each step of the game, proper message should be provided by the codemake (computer) to the codebreaker. For instance, at the beginning there would be a welcome message, followed by asking the codebreaker to guess the code. After each guess, an accurate feedback should be shown to the codebreaker. If codebreaker wins/loses, proper message showed be shown to the codebreaker as well. You can get some ideas from the sample execution of the program on page 4 of this document. Part B: Pseudocode: (40 marks) Using the above game rules, write the pseudocode (formal or informal) for the Mastermind game. As a hint, we start it as follows, and you should complete it: 1. Start 2. Show a Welcome message to the player. 3. Generate a random code. 4. ... Complete the next steps X. Ask the player if they want to play again or not a. If yes, go to step 3 b. If no, show a Goodbye message and end the program X+1. End Part C: Flowchart (40 marks) Using the pseudocode you wrote in the previous part, draw a flowchart for the Mastermind game. You can use any flowchart software, like Raptor, or simply draw it on any software with graphical capabilities, like Word, Excel, PowerPoint, Paintbrush, etc. Terminal src (Saeeds-MacBook Pro local) X bash-3.2$ /MasterMind Welcome to MasterMind Game !!! Version 4 Release Date: Jan. 10, 2020 Programmer: Saeed Samet. You have 10 remaining chance(s). Guess 4 numbers (enter @ to exit): 1 2 3 4 Correct Location & Number : Correct Number : 2 You have 9 remaining chance(s). Guess 4 numbers (enter @ to exit): 5 126 Correct Location & Number 10, Correct Number : 1 You have remaining chance(s). Guess 4 numbers (enter @to exit): 7 3 4 6 Correct Location & Number : Correct Number : 4 You have 7 remaining chance(s). Guess 4 numbers (enter @ to exit): 2 4 6 7 Correct Location & Number: 1. Correct Number: 3 You have 6 remaining chance(s). Guess 4 numbers (enter @ to exit): 6 4 7 3 Correct Location & Number : 4, Correct Number : @ Excellent!!! you solved it with 5 guesses, in 96 seconds. Do you want to play another game? (No:0, Yes: 1)1 You have 10 remaining chance(s). Guess 4 numbers (enter to exit): 1 1 1 1 Correct Location & Number : @, Correct Number : @ You have 9 remaining chance(s). Guess 4 numbers (enter to exit): 2 2 2 2 Correct Location & Number: 0, Correct Number: 0 You have 8 remaining chance(s). Guess 4 numbers (enter @ to exit): 3 3 3 3 Correct Location & Number : 0, Correct Number : You have 7 remaining chance(s). Guess 4 numbers (enter to exit): 4 4 4 4 Correct Location & Number: 0, Correct Number : You have 6 remaining chance(s). Guess 4 numbers (enter @ to exit): 5 5 5 5 Correct Location & Number: 1, Correct Number: 0 You have 5 remaining chance(s). Guess 4 numbers (enter to exit): 6 6 6 6 Correct Location & Number : 1, Correct Number : You have 4 remaining chance(s). Guess 4 numbers (enter @ to exit): 7 7 7 7 Correct Location & Number : 1, Correct Number : You have 3 remaining chance(s). Guess 4 numbers (enter @ to exit): 8 8 8 8 Correct Location & Number : 1, Correct Number : You have 2 remaining chance(s). Guess 4 numbers (enter o to exit): 5 Correct Location & Number : 2, Correct Number : 2 You have 1 remaining chance(s). Guess 4 numbers (enter @ to exit): 5 6 8 7 Correct Location & Number : 1, Correct Number : 3 Sorry, You Lost : Answer is:7 6 5 8 Do you want to play another game? (No:0, Yes: 1) bash-3.2$ 1 6 7 8

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Discuss the strategic importance of information.

Answered: 1 week ago

Question

please refer to the picture ( question have 2 parts )

Answered: 1 week ago