Mastermind is a code-breaking game for two players (https://en.wikipedia.org/wiki/Mastermind hidden code that consists of 4-5 code...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Mastermind is a code-breaking game for two players (https://en.wikipedia.org/wiki/Mastermind hidden code that consists of 4-5 code pegs. 2.1 The Board Game "Original Mastermind" The board 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 colours (Red, Green, Blue, Yellow, White, Black), with round heads, which will be placed in the large holes on the board; and (board game)). The goal of the game is to discover a • key pegs, some coloured black, some white, which are flat-headed and smaller than the code pegs; they will be placed in the small holes on the board. The two players decide in advance how many games they will play, which must be an even number. One player becomes the codemaker, the other the codebreaker. The codemaker chooses a pattern of four code pegs. Duplicates and blanks are allowed depending on player choice, so the player could even choose four code pegs of the same colour or four blanks. In the instance that blanks are not elected to be a part of the game, the codebreaker may not use blanks in order to establish the final code. 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 colour, within eight to twelve turns. Each guess is made by placing a row of code pegs on the decoding board. 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 colour and position. A white key peg indicates the existence of a correct colour code peg placed in the wrong position. If there are duplicate colours in the guess, they cannot all be awarded a key peg unless they correspond to the same number of duplicate colours in the hidden code. For example, if the hidden code is white-white-black-black and the player guesses white-white-white-black, the codemaker will award two black key pegs for the two correct whites, nothing for the third white as there is not a third white in the code, and a black key peg for the black. No indication is given of the fact that the code also includes a second black. 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. If the code is not guessed correctly within 12 attempts then the code is revealed. 2.2 The Board Game "Mastermind44" Mastermind44 is a variation of the original Mastermind for 4 players: https://boardgamegeek.com/boardgame/12467/mastermind44 The difference between the two versions of the game are in the length of the code, how the code is created, how feedback is provided, and the number of attempts for each player: ● ● . ● . . . ● ● ● ● 2.3 Adaptation for Implementation: For the implementation we will make some adaptations: There is always only one game played. Both versions, the Original and Mastermind44 must be supported by the ● The code consists of 5 coloured pegs. There are five black code counters that contain the numbers 1 to 5. They indicate the position of the code. There are white code counters that contain a colour. There are 5 white code counters for ● each colour. They will be used to select the colour of a position in the code. The code counters are placed upside down on the table so the number and the colours cannot be seen. The code is created by the four players: Each player picks a black (with a number) and a white (with a colour) code counter and secretly places them with the colour and number facing to them. One black code counter will remain on the table. This indicates a blank on the position in the code as indicated by that counter. One player makes a guess and then that player and the other players provide feedback with a black or white key peg (or nothing) depending on their secret black and white code counter. (Note, the player who makes a guess may put the correct coloured code peg in the correct position according to his/her secret black and white code counter. He must indicate this by a key peg in the feedback). Then the next player clockwise makes a guess and receives feedback from everyone else. Each player has 5 attempts. The first player who receives four black key pegs wins. If each player guesses 5 times and no player wins then the code is revealed. implementation. No blanks are allowed for the Original Mastermind and there will be one blank in the code for Mastermind44. The Original version will use a code consisting of 4 pegs. The Mastermind44 version will use a code consisting of 5 pegs. The Original Mastermind version will allow 12 attempts and the Mastermind44 version will allow 5 attempts for each player. The computer will always provide feedback for each guess automatically on the screen. No human input is required. Each version will allow two modes: (1) With or (2) without computer support. Computer support means that the secret code is generated automatically at the start of a game. In case of the Original Mastermind version, this means that it becomes a single player game. In this assignment, you will design and implement a text-based Mastermind game that fulfils the specification above.Text-based does not mean ASCII art but instead will be driven by a text-based menu interface. The aim of the assignment is to allow you to practise creating an object-oriented design and implementing it in Python using features such as class inheritance, polymorphism, and composition. The focus of the assignment is on identifying classes and applying appropriate relationships between the classes. The game should be designed in such a way that code is reused and can be extended easily. In this first part of the assignment you will need to develop a class design using UML class diagrams in UMLet based on the requirements above and in the remainder of this specification. The UML class diagram MUST include all necessary classes, public, protected, and private attributes and methods, and all relationships between classes. A brief example of how the game will be played is provided below. The remainder of the section describes the requirements of the game in more detail. Note: the following conventions will be used when illustrating the example output below: • A'>' at the beginning of a line indicates the command line prompt. • Abold orange text indicates input entered by the user • User input surrounded by square brackets '[...]' indicates a specific key press • hitting [Enter] after other input is implied Inside Visual Studio Code: m Mastermind () m.play() Welcome to Mastermind! Developed by Georg Grossmann COMP 1046 Object-Oriented Programming Select which game you want to play: (A) Original Mastermind for 2 Players. (B) Original Mastermind for 1 Player (C) Mastermind44 for 4 Players (D) Mastermind44 for 4 Players with Computer Support: *Press A, B, C, or D to continue+ > [a] What would you like to do? Welcome Tom Turbo, you need to create a code that consists of four pegs. Eeach pag can be of the colour (R)ed, B(L)ue, (G) reen, (Y) ellow, (W) hite, or (8) lack. Specify the code by specifying four characters where each character indicates a colour as above. For example, WWRG represents the code White-White-Red-Green. You need to enter the code twice. No character is shown on the screen so Supermind cannot see it. Enter the code now: >BYYG Enter the same code again: >BYYG The code was stored. Welcome Supermind. You can now start to play by guessing the code. Enter a guess by providing four characters and press Enter. Attempt #1: >ZBVVD This attempt is incorrect. You must provide exactly four characters and they can only be, R, L, G, Y, W or B. >WWWW Feedback on Attempt #1: Nothing. Attempt #2: >BGRY Feedback on Attempt #2: BWN Attempt #3: >BGWB Feedback on Attempt #3: BW Attempt #4: >BYGB Feedback on Attempt #4:B B W Attempt #5: >BYBG Feedback on Attempt #5: B BB Attempt #6: > BYYG Feedback on Attempt #6: B B B B Congratulations! You broke the code in 6 attempts. What would you like to do? (p) lay the game again (q) uit > [q] Goodbye! The description that follows is a high-level view of the requirements that is enough to perform the initial design. More detailed instructions will accompany the specification for Part 2 of this Assignment, which will allow you to implement the game's functionality. 3. Work Plan To complete the first part of this assignment, you will need to perform the following steps: 1. Read the assignment specification carefully. 2. Review the relationships between classes in a UML class diagram: inheritance, association, aggregation, and composition. Identify which classes are necessary to capture the requirements. Identify attributes and methods of those classes. Specify public, private or protected for them as well as parameter names of methods, data types for attributes and data types for return values of methods. 5. Identify relationships between classes and add cardinalities where applicable, and add a label to the relationship. 6. Revisit all classes and see if you can use inheritance to minimize duplication of code. If you have an abstract class, then set its name in italic. 7. 8. You can add annotations to classes if it helps you later with the implementation (e.g., responsibilities of classes). 3. 4. Identifying all methods and attributes does not have to be complete or 100% correct at this point in time. It will give you the opportunity to think about the structure and flow of the application before starting the implementation. You can revise it later as you progress through the implementation, for example, you may realise you are missing some arguments to a member function or missing an entire function. The marking of this aspect will focus on the appropriate classes and relationships, separation of concerns, and good naming. After completing the design, generate a PNG and copy it into a Word document or generate a PDF version from the diagram and submit it to Moodle. Mastermind is a code-breaking game for two players (https://en.wikipedia.org/wiki/Mastermind hidden code that consists of 4-5 code pegs. 2.1 The Board Game "Original Mastermind" The board 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 colours (Red, Green, Blue, Yellow, White, Black), with round heads, which will be placed in the large holes on the board; and (board game)). The goal of the game is to discover a • key pegs, some coloured black, some white, which are flat-headed and smaller than the code pegs; they will be placed in the small holes on the board. The two players decide in advance how many games they will play, which must be an even number. One player becomes the codemaker, the other the codebreaker. The codemaker chooses a pattern of four code pegs. Duplicates and blanks are allowed depending on player choice, so the player could even choose four code pegs of the same colour or four blanks. In the instance that blanks are not elected to be a part of the game, the codebreaker may not use blanks in order to establish the final code. 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 colour, within eight to twelve turns. Each guess is made by placing a row of code pegs on the decoding board. 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 colour and position. A white key peg indicates the existence of a correct colour code peg placed in the wrong position. If there are duplicate colours in the guess, they cannot all be awarded a key peg unless they correspond to the same number of duplicate colours in the hidden code. For example, if the hidden code is white-white-black-black and the player guesses white-white-white-black, the codemaker will award two black key pegs for the two correct whites, nothing for the third white as there is not a third white in the code, and a black key peg for the black. No indication is given of the fact that the code also includes a second black. 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. If the code is not guessed correctly within 12 attempts then the code is revealed. 2.2 The Board Game "Mastermind44" Mastermind44 is a variation of the original Mastermind for 4 players: https://boardgamegeek.com/boardgame/12467/mastermind44 The difference between the two versions of the game are in the length of the code, how the code is created, how feedback is provided, and the number of attempts for each player: ● ● . ● . . . ● ● ● ● 2.3 Adaptation for Implementation: For the implementation we will make some adaptations: There is always only one game played. Both versions, the Original and Mastermind44 must be supported by the ● The code consists of 5 coloured pegs. There are five black code counters that contain the numbers 1 to 5. They indicate the position of the code. There are white code counters that contain a colour. There are 5 white code counters for ● each colour. They will be used to select the colour of a position in the code. The code counters are placed upside down on the table so the number and the colours cannot be seen. The code is created by the four players: Each player picks a black (with a number) and a white (with a colour) code counter and secretly places them with the colour and number facing to them. One black code counter will remain on the table. This indicates a blank on the position in the code as indicated by that counter. One player makes a guess and then that player and the other players provide feedback with a black or white key peg (or nothing) depending on their secret black and white code counter. (Note, the player who makes a guess may put the correct coloured code peg in the correct position according to his/her secret black and white code counter. He must indicate this by a key peg in the feedback). Then the next player clockwise makes a guess and receives feedback from everyone else. Each player has 5 attempts. The first player who receives four black key pegs wins. If each player guesses 5 times and no player wins then the code is revealed. implementation. No blanks are allowed for the Original Mastermind and there will be one blank in the code for Mastermind44. The Original version will use a code consisting of 4 pegs. The Mastermind44 version will use a code consisting of 5 pegs. The Original Mastermind version will allow 12 attempts and the Mastermind44 version will allow 5 attempts for each player. The computer will always provide feedback for each guess automatically on the screen. No human input is required. Each version will allow two modes: (1) With or (2) without computer support. Computer support means that the secret code is generated automatically at the start of a game. In case of the Original Mastermind version, this means that it becomes a single player game. In this assignment, you will design and implement a text-based Mastermind game that fulfils the specification above.Text-based does not mean ASCII art but instead will be driven by a text-based menu interface. The aim of the assignment is to allow you to practise creating an object-oriented design and implementing it in Python using features such as class inheritance, polymorphism, and composition. The focus of the assignment is on identifying classes and applying appropriate relationships between the classes. The game should be designed in such a way that code is reused and can be extended easily. In this first part of the assignment you will need to develop a class design using UML class diagrams in UMLet based on the requirements above and in the remainder of this specification. The UML class diagram MUST include all necessary classes, public, protected, and private attributes and methods, and all relationships between classes. A brief example of how the game will be played is provided below. The remainder of the section describes the requirements of the game in more detail. Note: the following conventions will be used when illustrating the example output below: • A'>' at the beginning of a line indicates the command line prompt. • Abold orange text indicates input entered by the user • User input surrounded by square brackets '[...]' indicates a specific key press • hitting [Enter] after other input is implied Inside Visual Studio Code: m Mastermind () m.play() Welcome to Mastermind! Developed by Georg Grossmann COMP 1046 Object-Oriented Programming Select which game you want to play: (A) Original Mastermind for 2 Players. (B) Original Mastermind for 1 Player (C) Mastermind44 for 4 Players (D) Mastermind44 for 4 Players with Computer Support: *Press A, B, C, or D to continue+ > [a] What would you like to do? Welcome Tom Turbo, you need to create a code that consists of four pegs. Eeach pag can be of the colour (R)ed, B(L)ue, (G) reen, (Y) ellow, (W) hite, or (8) lack. Specify the code by specifying four characters where each character indicates a colour as above. For example, WWRG represents the code White-White-Red-Green. You need to enter the code twice. No character is shown on the screen so Supermind cannot see it. Enter the code now: >BYYG Enter the same code again: >BYYG The code was stored. Welcome Supermind. You can now start to play by guessing the code. Enter a guess by providing four characters and press Enter. Attempt #1: >ZBVVD This attempt is incorrect. You must provide exactly four characters and they can only be, R, L, G, Y, W or B. >WWWW Feedback on Attempt #1: Nothing. Attempt #2: >BGRY Feedback on Attempt #2: BWN Attempt #3: >BGWB Feedback on Attempt #3: BW Attempt #4: >BYGB Feedback on Attempt #4:B B W Attempt #5: >BYBG Feedback on Attempt #5: B BB Attempt #6: > BYYG Feedback on Attempt #6: B B B B Congratulations! You broke the code in 6 attempts. What would you like to do? (p) lay the game again (q) uit > [q] Goodbye! The description that follows is a high-level view of the requirements that is enough to perform the initial design. More detailed instructions will accompany the specification for Part 2 of this Assignment, which will allow you to implement the game's functionality. 3. Work Plan To complete the first part of this assignment, you will need to perform the following steps: 1. Read the assignment specification carefully. 2. Review the relationships between classes in a UML class diagram: inheritance, association, aggregation, and composition. Identify which classes are necessary to capture the requirements. Identify attributes and methods of those classes. Specify public, private or protected for them as well as parameter names of methods, data types for attributes and data types for return values of methods. 5. Identify relationships between classes and add cardinalities where applicable, and add a label to the relationship. 6. Revisit all classes and see if you can use inheritance to minimize duplication of code. If you have an abstract class, then set its name in italic. 7. 8. You can add annotations to classes if it helps you later with the implementation (e.g., responsibilities of classes). 3. 4. Identifying all methods and attributes does not have to be complete or 100% correct at this point in time. It will give you the opportunity to think about the structure and flow of the application before starting the implementation. You can revise it later as you progress through the implementation, for example, you may realise you are missing some arguments to a member function or missing an entire function. The marking of this aspect will focus on the appropriate classes and relationships, separation of concerns, and good naming. After completing the design, generate a PNG and copy it into a Word document or generate a PDF version from the diagram and submit it to Moodle.
Expert Answer:
Answer rating: 100% (QA)
Certainly it seems youre looking for guidance on designing a textbased Mastermind game using objecto... View the full answer
Related Book For
Statistics For Management And Economics Abbreviated
ISBN: 9781285869643
10th Edition
Authors: Gerald Keller
Posted Date:
Students also viewed these programming questions
-
A customer at Cavallaro's Fruit Stand picks a sample of 4 oranges at random from a crate containing 45 oranges, of which 6 are rotten. What is the probability that the sample contains 2 or more...
-
Under the SEC's rules, accountants are not considered to be independent if they: Multiple choice question. properly disclose all conflicts of interest maintain bank accounts with an audit client with...
-
The formal study of probability began with questions regarding gambling and games of chance. The conventional analysis of gambling is based on the expected values of these games which is always...
-
Barbara buys 100 shares of DEM at $35 a share and 200 shares of GOP at $40 a share. She buys on margin and the broker charges interest of 10 percent on the loan. a. If the margin requirement is 55...
-
Various Changes in PrincipleInventory Methods Below is the net income of Benchley Instrument Co., a private corporation, computed under the three inventory methods using a periodic system. FIFO...
-
Sketch the limacon r = 2 - 3 cos , and find the area of the region inside its large loop.
-
Dairymaids yogurt goes through two sequential processes in two departments: Fermenting and Packaging. Assume that in the Packaging Department, Step 4 of the process costing procedure indicated the...
-
You have been asked by the board of trustees of a local church to review its accounting procedures. As part of this review you have prepared the following comments about the collections made at...
-
1. A planet is revolving around the sun in an elliptical orbit. The mass of planet is m, angular momentum of planet about sun is L, and length of semi major axis is a and eccentricity is e. Time...
-
You will play the roles of a Freight Forwarder and a materials and distribution manager for Apotex Pharmaceuticals in Toronto. Your role is the materials and distribution manager for Apotex...
-
Virginia Thomton owns 25 acres of land. If she grows corn on (2)/(3) of her land, how many acres does she have left for trest of her crops?
-
Suppose Jack Major, one of your firms clients, owns a Rottweiler dog by the name of Misty, who recently bit a door-to-door salesman who came to their home. Jack is concerned that he will be sued and...
-
Your firm has a client, Ken, who purchased an Arabian stallion from Ellie Arabians. His intent was to use the stallion to enhance his breeding program, but in the first year that he used the...
-
Your firm has agreed to represent Michael, the victim of a school shooting. The evidence your investigator has been able to gather at this point indicates that the suspected assailants had been avid...
-
Arco1 Ltd and Arco2 Ltd are both 100% subsidiaries of Headco Ltd, which has no other subsidiaries. They are all UK resident. How will the relationship of the three companies affect the way in which...
-
During the year to 31 March 2018 , a company which qualifies as medium-sized spends 180,000 on research and development . This is qualifying expenditure under the R&D tax relief scheme. Explain the...
-
Flywest Airlines, Inc. has regular taxable income of $190million. It also has $10 million of AMT preference items, a $5million unfavorable depreciation adjustment, and a $2 millionfavorable ACE...
-
For the following exercises, write the polynomial function that models the given situation. Consider the same rectangle of the preceding problem. Squares of 2x by 2x units are cut out of each corner....
-
A gambler believes that a strategy called "doubling up" is an effective way to gamble. The method requires the gambler, to double the stake after each loss. Thus, if the initial bet is $1, after...
-
The Nielsen Ratings estimate the numbers of televisions tuned to various channels. However, television executives need more information. The General Social Survey may be the source of this...
-
It has been estimated that the oil sands in Alberta Canada contain 2 trillion barrels of oil. However, recovering the oil damages the environment. A survey of Canadians and Americans was asked, what...
-
Combined separating and throttling calorimeter is used to find out dryness fraction of steam, following readings were taken: Main pressure \(=12\) bar abs. Mass of water collected in separating...
-
Determine the quality of steam for the following cases: (i) \(P=10\) bar, \(v=0.180 \mathrm{~m}^{3} / \mathrm{k}\) (ii) \(P=10\) bar, \(t=200^{\circ} \mathrm{C}\) (iii) \(P=25 \mathrm{bar}, h=2,750...
-
Steam at \(1,000 \mathrm{kPa}\) and \(300^{\circ} \mathrm{C}\) enters an engine and expands to \(20 \mathrm{kPa}\). If the exhaust steam has a dryness fraction of 0.9 , make calculations for the drop...
Study smarter with the SolutionInn App