Develop a simple game application using Python Programming

User Generated

cerm

Programming

Description

Using Python Programming develop a code that without using the data type dictionary to play Mastermind and another that with the help of dictionary

- Develop a simple game application without using the data type dictionary. Allow any number of players to play MasterMind together.

- Use the data type dictionary to record each player’s name, score for the current game and the number of games won thus far. Use the data type dictionary for any other appropriate values.

Unformatted Attachment Preview

ICT133 Structured Programming Tutor-Marked Assignment July 2018 Presentation TUTOR-MARKED ASSIGNMENT (TMA) This assignment is worth 18 % of the final mark for ICT133, Structured Programming. Submit as Text, not python software. The cut-off date for this assignment is Friday, 07 September 2018, 2355 hours. Note to Students: You are to include the following particulars in your submission: Course Code, Title of the TMA, SUSS PI No., Your Name, and Submission Date. ICT133 Tutor-Marked Assignment Answer all questions. Question 1 Develop a simple game application without using the data type dictionary. Allow any number of players to play MasterMind together. Take current player points – previous player points, easier method. To take note if there’s any For the game design and implementation, you must adhere to the following constraints: Game Play: • Start the application by asking the user how many players will be playing MasterMind and the names of the players. • Before each new game commences, the application randomly generates a hidden code. • To generate the hidden code, the application makes 4 random choices to pick 4 different colors from 6 colors (stored as a string "RGBYOP"). The letters represent the 6 distinct colors: Red, Green, Blue, Yellow, Orange and Purple. The random choices are stored as a single string e.g., "YBRP". • Players take turns to make a guess, the order follows the order the names are entered. When it is a player’s turn, he guesses the colors and positions of the hidden code. The guess is read as a string and consists of 4 letters e.g., "BORY". The result of his guess is displayed before the next player takes his turn. Show both the before and after score of a player after his guess is checked. • The next player then takes his turn, each guess is checked and the score updated, until the game ends when the hidden code is broken, that is, a player gets 4 black pins. At the end of each game, print out the details of the players and list the winner(s). The output should be shown on both screen and file. • The players can repeatedly decide whether to play another game of MasterMind. If the players decide to stop play, print out the players with the most number of games won. The output should be shown on both screen and file. Computation of scores and winners: • Each right color in the wrong position earns the player a white pin which is worth 1 point, and each right color in the right position earns the player a black pin or 5 points. In this example, the guess earns 2 white SINGAPORE UNIVERSITY OF SOCIAL SCIENCES (SUSS) Page 2 of 6 ICT133 Tutor-Marked Assignment pins and 1 black pin, and the program displays WWB, subjected to this consideration: Only additional pins a player gets will earn him points. • Only additional pins a player gets will earn him points. For example, assume that throughout game play thus far, the best performance for white pins is 2 and the best performance for black pins is 0. If now, a player guesses and gets a black pin and a white pin, he will be awarded 5 more points as he has 1 additional black pin. His white pin does not earn him any points as he has no additional white pin. • At the end of each game, add 1 to the number of games won to the player that breaks the code and to any player that has the most points for that game. Therefore, a player that breaks the code and who also has the most points will have 2 added to the number of games won thus far. • When the players decide to stop playing, print out the players with the most number of games won. The output should be shown on both screen and file. A sample run of the program is shown below: Screen: Enter number of players: 3 Enter player's name: alan Enter player's name: betty Enter player's name: cindy Alan, make a guess of 4 colors from RGBYOP: BYOP Result WWB Current Player: Alan Current Score: 0 Current Player: Alan Updated Score: 7 Betty, make a guess of 4 colors from RGBYOP: BYOR Result WB Current Player: Betty Current Score: 0 Current Player: Betty Updated Score: 0 Cindy, make a guess of 4 colors from RGBYOP: BYPG Result WWWB Current Player: Cindy Current Score: 0 Current Player: Cindy Updated Score: 1 Alan, make a guess of 4 colors from RGBYOP: BPGY Result BBBB Current Player: Alan Current Score: 7 Current Player: Alan Updated Score: 22 Correct guess! [['Alan', 22, 2], ['Betty', 0, 0], ['Cindy', 1, 0]] Winner: ['Alan', 22, 2] to play and any letter to stop: Alan, make a guess of 4 colors from RGBYOP: RGBY Result WBB Current Player: Alan Current Score: 0 Current Player: Alan Updated Score: 11 Betty, make a guess of 4 colors from RGBYOP: ORBY SINGAPORE UNIVERSITY OF SOCIAL SCIENCES (SUSS) Page 3 of 6 ICT133 Tutor-Marked Assignment Result BBBB Current Player: Betty Current Score: 0 Current Player: Betty Updated Score: 10 Correct guess! [['Alan', 11, 3], ['Betty', 10, 1], ['Cindy', 0, 0]] Winner: ['Betty', 10, 1] to play and any letter to stop: s Overall Winner: ['Alan', 11, 3] Program end File: [['Alan', 22, 2], ['Betty', 0, 0], ['Cindy', 1, 0]] Winner: ['Alan', 22, 2] [['Alan', 11, 3], ['Betty', 10, 1], ['Cindy', 0, 0]] Winner: ['Betty', 10, 1] Overall Winner: ['Alan', 11, 3] (a) Demonstrate how you implement top-down design to the problem, showing at least 3 levels of refinement. Show also the final set of functions derived from your top-down design in a structure chart. (10 marks) (b) Implement your solution based on your structure chart in part Q3(a) and specify the order in which you test your functions. (20 marks) Question 2 (a) Modify the game application in question Q3: • Use the data type dictionary to record each player’s name, score for the current game and the number of games won thus far. Use the data type dictionary for any other appropriate values. • Before each new game commences, besides randomly generating a hidden code, the application also randomly orders the players to take turn in that order (10 marks) (b) Justify the data types used for the data values used in your program using terms such as mutable, immutable, scalar and collection. (5 marks) SINGAPORE UNIVERSITY OF SOCIAL SCIENCES (SUSS) Page 4 of 6 ICT133 Tutor-Marked Assignment A sample run of the program is shown below: Enter number of players: 3 Enter player's name: alan Enter player's name: betty Enter player's name: collin Playing in this order ['Alan', 'Collin', 'Betty'] Alan, make a guess of 4 colors from RGBYOP: rgby Result WB Current Player: Alan Current Score: 0 Current Player: Alan Updated Score: 6 Collin, make a guess of 4 colors from RGBYOP: rbyp Result WW Current Player: Collin Current Score: 0 Current Player: Collin Updated Score: 1 Betty, make a guess of 4 colors from RGBYOP: pgoy Result WWBB Current Player: Betty Current Score: 0 Current Player: Betty Updated Score: 5 Alan, make a guess of 4 colors from RGBYOP: gpoy Result BBBB Current Player: Alan Current Score: 6 Current Player: Alan Updated Score: 16 Correct guess! {'Alan': {'score': 16, 'won': 2}, 'Betty': {'score': 5, 'won': 0}, 'Collin': {'score': 1, 'won': 0}} Winner: Alan {'score': 16, 'won': 2} to play and any letter to stop: Playing in this order ['Betty', 'Collin', 'Alan'] Betty, make a guess of 4 colors from RGBYOP: rgby Result WBB Current Player: Betty Current Score: 0 Current Player: Betty Updated Score: 11 Collin, make a guess of 4 colors from RGBYOP: rbgo Result WBB Current Player: Collin Current Score: 0 Current Player: Collin Updated Score: 0 Alan, make a guess of 4 colors from RGBYOP: yrbg Result WWW Current Player: Alan Current Score: 0 Current Player: Alan Updated Score: 2 Betty, make a guess of 4 colors from RGBYOP: rogy Result BBBB Current Player: Betty Current Score: 11 Current Player: Betty Updated Score: 21 Correct guess! {'Alan': {'score': 2, 'won': 2}, 'Betty': {'score': 21, 'won': 2}, 'Collin': {'score': 0, 'won': 0}} Winner: Betty {'score': 21, 'won': 2} to play and any letter to stop: s SINGAPORE UNIVERSITY OF SOCIAL SCIENCES (SUSS) Page 5 of 6 ICT133 Tutor-Marked Assignment Overall Winner: Alan Overall Winner: Betty Program end Do not need to produce same output as this. ---- END OF ASSIGNMENT ---- SINGAPORE UNIVERSITY OF SOCIAL SCIENCES (SUSS) Page 6 of 6
Purchase answer to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

Am fin...

Similar Content

Related Tags