Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 3 (28 marks) Extend the single-player guessing game to a game for 1 to 4 players. In addition, the players can choose to play
Question 3 (28 marks) Extend the single-player guessing game to a game for 1 to 4 players. In addition, the players can choose to play with addition puzzles using n-digit numbers where n is a number from 1 to 3. Players are given points based on their guesses, and they can play repeatedly. Study the sample program output and the accompanying notes to apply for the problem requirements. User input is shown underlined. Player name or to end: Note: There must be a minimum of 1 There must be at least one player! player and a maximum of 4 players Player name or to end: anna with no repeated names. Player name or to end: anna Anna is already is player list Player name or to end: betty Player name or to end: Charlie Player name or to end: Dennis Choose number of digits for each number in addition (1-3): 0 Choose number of digits for each number in addition (1-3): 5 Choose number of digits for each number in addition (1-3): 2 4-player Game *Cheat Sheet* Note: Display a cheat sheet to help 69 you and the marker test your + 99 program, 168 gf + ff hgd Note: Each player starts with zero points in the first game. Accumulate points across games thereafter. >>>>> Player Anna Current points = 0 >>>> Player Betty Current points = 0 >>>> Player Charlie Current points = 0 >>>> Player Dennis Current points = 0 >>>> Player Anna Current points = 0 >>>> Player Betty Current points = 0 >>>> Player Charlie Current points Enter a letter: g Enter a digit: 6 69 + 99 Note: A player who makes a right guess and ends the game earns 5 points instead of 2. 168 Players can choose whether to play a new game. Player Charlie wins this game. Updated points = 7 Enter any non-whitespace character to play again or to end: d *Cheat Sheet* 90 + 45 135 aj + bc Note: digits are reassigned letters in each game. Note that the letter d in game 1 is 9 but in game 2, the letter d is 3. edc Note: Part of the run has been removed to reduce the length. >>>>> Player Betty Current points = 4 to end: Player Name Points Betty Charlie Note: Show the players in Dennis descending order of points and in Anna alphabetical order of name. Application ends 9 9 4 4 The required tasks for the program are as follows: (a) Puzzle Logic To generate random number of n-digit. To replace the digits of a number with letters based on the mapping. To update the letters in the puzzle with guessed digits. (7 marks) (b) Game Logic To get the required random numbers, transformation mapping and to set up the puzzle. To display the cheat sheet and puzzle. To allow players to take turn in guessing the digits for the letters. To allocate points to players based on their guesses. The points are accumulated over games. To display the updated puzzle. To determine whether the puzzle is solved, and if so, to end the game. (11 marks) Overall main logic To read the names of 1 to 4 players with no duplicate. To read n, the number of digits where n is between 1 and 3. To repeatedly allow players to play a game until the players choose to end. To display the players' name and their points, in descending order of points and ascending order of player names. (10 marks) (c) Notes: 1. You may make use of un-nested lists but NOT dictionary. Except for the last task of part i) To display the players' name and their points, for which you may use nested list, you should NOT use nested data structure, that is, lists within list in any other parts of your program. Question 3 (28 marks) Extend the single-player guessing game to a game for 1 to 4 players. In addition, the players can choose to play with addition puzzles using n-digit numbers where n is a number from 1 to 3. Players are given points based on their guesses, and they can play repeatedly. Study the sample program output and the accompanying notes to apply for the problem requirements. User input is shown underlined. Player name or to end: Note: There must be a minimum of 1 There must be at least one player! player and a maximum of 4 players Player name or to end: anna with no repeated names. Player name or to end: anna Anna is already is player list Player name or to end: betty Player name or to end: Charlie Player name or to end: Dennis Choose number of digits for each number in addition (1-3): 0 Choose number of digits for each number in addition (1-3): 5 Choose number of digits for each number in addition (1-3): 2 4-player Game *Cheat Sheet* Note: Display a cheat sheet to help 69 you and the marker test your + 99 program, 168 gf + ff hgd Note: Each player starts with zero points in the first game. Accumulate points across games thereafter. >>>>> Player Anna Current points = 0 >>>> Player Betty Current points = 0 >>>> Player Charlie Current points = 0 >>>> Player Dennis Current points = 0 >>>> Player Anna Current points = 0 >>>> Player Betty Current points = 0 >>>> Player Charlie Current points Enter a letter: g Enter a digit: 6 69 + 99 Note: A player who makes a right guess and ends the game earns 5 points instead of 2. 168 Players can choose whether to play a new game. Player Charlie wins this game. Updated points = 7 Enter any non-whitespace character to play again or to end: d *Cheat Sheet* 90 + 45 135 aj + bc Note: digits are reassigned letters in each game. Note that the letter d in game 1 is 9 but in game 2, the letter d is 3. edc Note: Part of the run has been removed to reduce the length. >>>>> Player Betty Current points = 4 to end: Player Name Points Betty Charlie Note: Show the players in Dennis descending order of points and in Anna alphabetical order of name. Application ends 9 9 4 4 The required tasks for the program are as follows: (a) Puzzle Logic To generate random number of n-digit. To replace the digits of a number with letters based on the mapping. To update the letters in the puzzle with guessed digits. (7 marks) (b) Game Logic To get the required random numbers, transformation mapping and to set up the puzzle. To display the cheat sheet and puzzle. To allow players to take turn in guessing the digits for the letters. To allocate points to players based on their guesses. The points are accumulated over games. To display the updated puzzle. To determine whether the puzzle is solved, and if so, to end the game. (11 marks) Overall main logic To read the names of 1 to 4 players with no duplicate. To read n, the number of digits where n is between 1 and 3. To repeatedly allow players to play a game until the players choose to end. To display the players' name and their points, in descending order of points and ascending order of player names. (10 marks) (c) Notes: 1. You may make use of un-nested lists but NOT dictionary. Except for the last task of part i) To display the players' name and their points, for which you may use nested list, you should NOT use nested data structure, that is, lists within list in any other parts of your program
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started