Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please solve patr c. Thanks. Mastermind or Master Mind is a code-breaking game for two players. The modern game with pegs was invented in 1970

image text in transcribed

image text in transcribed

Please solve patr c. Thanks.

Mastermind or Master Mind is a code-breaking game for two players. The modern game with pegs was invented in 1970 by Mordecai Meirowitz, an Israeli postmaster and telecommunications expert. The game is played using: a decoding board, with a shield at one end covering a row of four large holes, and twelve (or ten, or eight, or six) additional rows containing four large holes next to a set of four small holes; code pegs of six different colors (or more; see Variations below), with round heads, which will be placed in the large holes on the board; and key pegs, some colored black, some white, which are flat-headed and smaller than the code pegs; they will be placed in the small holes on the board. One player becomes the codemaker, the other the codebreaker. The codemaker chooses a pattern of four code pegs. In this version, we assume that duplicates and blanks are not. The chosen pattern is placed in the four holes covered by the shield, visible to the codemaker but not to the codebreaker. The codebreaker tries to guess the pattern, in both order and color, within eight to twelve turns. Each guess is made by placing a row of code pegs on the decoding board. Codebreaker can use duplication for each set of guess. Once placed, the codemaker provides feedback by placing from zero to four key pegs in the small holes of the row with the guess. A black key peg is placed for each code peg from the guess which is correct in both color and position. A white key peg indicates the existence of a correct color code peg placed in the wrong position. However, there is no relation between the order of black and white key pegs and the order of the guessed pattern. If there are duplicate colors in the guess, only the left most of them, will be considered by the codemaker to provide feedback. Once feedback is provided, another guess is made; guesses and feedback continue to alternate until either the codebreaker guesses correctly, or twelve (or ten, or eight) incorrect guesses are made. For instance, on the picture above, codemaker has selected blue, green, black and red. The first guess by the codebreaker is white, blue, yellow, and green. Therefore, the feedback includes only two white pegs, which means there are only two right colors (blue and green) but incorrect locations. After the second guess, blue, yellow, red and black, the feedback includes one black (for the blue one) and two white pegs (for the red and black ones). (* You can install the game app on your device and play with it to have some FUN and learn its simple logic and rules. *) 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 C: Flowchart (50 marks) Draw a flowchart, optionally using the pseudocode you possibly wrote in the previous part, for the Mastermind game. You can use any flowchart software, like Raptor or Flowgorithm, or simply draw it on any software with graphical capabilities, like Word, Excel, PowerPoint, etc. 2 Mastermind or Master Mind is a code-breaking game for two players. The modern game with pegs was invented in 1970 by Mordecai Meirowitz, an Israeli postmaster and telecommunications expert. The game is played using: a decoding board, with a shield at one end covering a row of four large holes, and twelve (or ten, or eight, or six) additional rows containing four large holes next to a set of four small holes; code pegs of six different colors (or more; see Variations below), with round heads, which will be placed in the large holes on the board; and key pegs, some colored black, some white, which are flat-headed and smaller than the code pegs; they will be placed in the small holes on the board. One player becomes the codemaker, the other the codebreaker. The codemaker chooses a pattern of four code pegs. In this version, we assume that duplicates and blanks are not. The chosen pattern is placed in the four holes covered by the shield, visible to the codemaker but not to the codebreaker. The codebreaker tries to guess the pattern, in both order and color, within eight to twelve turns. Each guess is made by placing a row of code pegs on the decoding board. Codebreaker can use duplication for each set of guess. Once placed, the codemaker provides feedback by placing from zero to four key pegs in the small holes of the row with the guess. A black key peg is placed for each code peg from the guess which is correct in both color and position. A white key peg indicates the existence of a correct color code peg placed in the wrong position. However, there is no relation between the order of black and white key pegs and the order of the guessed pattern. If there are duplicate colors in the guess, only the left most of them, will be considered by the codemaker to provide feedback. Once feedback is provided, another guess is made; guesses and feedback continue to alternate until either the codebreaker guesses correctly, or twelve (or ten, or eight) incorrect guesses are made. For instance, on the picture above, codemaker has selected blue, green, black and red. The first guess by the codebreaker is white, blue, yellow, and green. Therefore, the feedback includes only two white pegs, which means there are only two right colors (blue and green) but incorrect locations. After the second guess, blue, yellow, red and black, the feedback includes one black (for the blue one) and two white pegs (for the red and black ones). (* You can install the game app on your device and play with it to have some FUN and learn its simple logic and rules. *) 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 C: Flowchart (50 marks) Draw a flowchart, optionally using the pseudocode you possibly wrote in the previous part, for the Mastermind game. You can use any flowchart software, like Raptor or Flowgorithm, or simply draw it on any software with graphical capabilities, like Word, Excel, PowerPoint, etc. 2

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_2

Step: 3

blur-text-image_3

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

Mastering Real Time Analytics In Big Data A Comprehensive Guide For Everyone

Authors: Lennox Mark

1st Edition

B0CPTC9LY9, 979-8869045706

More Books

Students also viewed these Databases questions

Question

Practice mobile reach in order to meet marketing goals.

Answered: 1 week ago

Question

3. How has e-commerce transformed marketing?

Answered: 1 week ago