Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Solve using python Question 3 Develop an NxN memory card game and allow 2-4 players to play. On the face of each card is a

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Solve using python

Question 3 Develop an NxN memory card game and allow 2-4 players to play. On the face of each card is a single letter, A-Z. The cards are shuffled and randomly placed face down in N-column and N-row grid. Players take turn to pick two cards at each turn. Whenever a player picks 2 cards with matching letters, the cards are placed face up, and the player earns one point. The player gets to pick another pair repeatedly until the letters do not match or there are no more cards to pick. The game can be placed at 2 levels: Level 1 N is 4, resulting in a 4x4 grid. Letters are randomly chosen and assigned to either 2 cards or 4 cards, repeatedly until 16 cards have been assigned letters. Level 2 N is an integer between 2 to 7. If the number of cells in the grid is odd, the last grid position is left empty and is marked NIL so only an even number of cards will be used in each game. For example, when N is 3, 5 or 7, there are 8, 24 or 48 cards respectively. Letters are randomly chosen and assigned to either only 1 card or 2 cards. The letters on cards may come in pairs (50% chance) or there can be exactly 2 letters without a match (50% chance). Implement the memory card game. Your collections can be ONLY of these types: un- nested lists, dict or str collections. Note: The implementation of level 2 game play is worth 14 marks. You may implement level 1 first and then build level 2 on top of the implementation for level 1. Start the application by getting the names of the players. There should be 2 to 4 players with no repeating names. The same set of players will play one or more memory games until the application ends. Before each new game commences, the application randomly orders the players, and this will be the order that the players take their turn. Allow the player to choose a game level. If the input is invalid, allow data entry to be repeated. The valid game level is either 1 or 2. If the game level is 1, do not prompt for grid size. If the game level is 2, the players choose a grid size. If the input is invalid, allow data entry to be repeated. The valid grid size is between 2 and 7. The application generates the cards according to the grid size (4x4 for level 1) and the constraints as specified for the game level, and the cards are shuffled. The application displays the cards face down and matched cards are displayed face up. Display NIL in the last grid position when N is odd (for level 2). At the start of each game, display a cheat sheet to help you test your program. The players take turn to pick until there are no more cards to pick (for both levels) or when the last two remaining cards do not match (for level 2 only). Display the score of a player when it is the player's turn to pick two cards. To pick a card, the player specifies the row and column numbers. Validate the row and column numbers, e.g., not NIL (for level 2 only), not a card that is already placed face up (for both levels), not outside grid boundary (for both levels) and the two cards picked are different cards. Display the updated score if the picked cards match. When the game ends, display the players with the most pairs of cards matched, in alphabetical order of names of players that tie. Then prompt whether the players wish to play a new game. If so, allow the players to choose a grid size and the game level. Example run Enter player name or to exit (min 2, max 4 players): Minimum 2 players. Currently, player Enter player name or to exit (min 2, max 4 players): ben Enter player name or to exit (min 2, max 4 players): Minimum 2 players. Currently, 1 player Enter player name or to exit (min 2, max 4 players): BEN Repeated name. Choose another name Enter player name or to exit (min 2, max 4 players): cindy Enter player name or to exit (min 2, max 4 players): alan Enter player name or to exit (min 2, max 4 players): Enter game level(1 to 2): -1 Please enter a valid game level Enter game level(1 to 2): 3 Please enter a valid game level Enter game level(1 to 2): 1 *** Cheat Sheet *** Columns Rows | 1 | 2 | 3 | 4 11 HIS IS 21 VIGTITI 310 GIVI 40 IIH! *** End Cheat Sheet *** Starting new game Columns Rows | 1 | 2 | 3 | 4 11 21 311 41 Player Cindy, enter your guess Current number of correct pairs: 8 Enter first card row and column, separated by space: 18 19 Please choose a card row and column within the grid Enter first card row and column, separated by space: 11 Open H Enter second card row and column, separated by space: 11 Please choose a different row and column from your earlier choice Enter second card row and column, separated by space: 4 4 Open H Correct !!!! Updated number of correct pairs: 1 Columns Rows | 1 | 2 | 3 | 4 | 11 HUIL 21 III 311 4 IIH! Player Cindy, enter your guess Current number of correct pairs: 1 Enter first card row and column, separated by space: 11 Please choose a card that is not face up yet Enter first card row and column, separated by space: 23 Open T Enter second card row and column, separated by space: 24 Open T Correct !!!! Updated number of correct pairs: 2 Columns Rows | 1 | 2 | 3 | 4 | 11 H11 21 1 IT IT! 31 4 LITH Player Cindy, enter your guess Current number of correct pairs: 2 Enter first card row and column, separated by space: 1 2 Open s Enter second card row and column, separated by space: 13 Open 1 Non-matching. No update Columns Rows | 1 | 2 | 3 | 41 21 TIT 31 41 LIH Player Alan, enter your guess Current number of correct pairs: Enter first card row and column, separated by space: 1 2 Open s Enter second card row and column, separated by space: 14 Open s Correct !!!! Updated number of correct pairs: 1 Columns ROWS 1 1 2 3 41 1. HIS 21 ! ||| 31 4 III Player Alan, enter your guess Current number of correct pairs: 1 Enter first card row and column, separated by space: 13 Open I Enter second card row and column, separated by space: 3 4 Open 1 Correct !!!! Updated number of correct pairs: 2 Columns Rows | 1 | 2 | 3 | 4 | 1 HIS IS 21 IT IT! 31 11 4| | | | | | Player Alan, enter your guess Current number of correct pairs: 2 Enter first card row and column, separated by space: 21 Open v Enter second card row and column, separated by space: 2 2 Open G Non-matching. No update Columns ROWS 1 2 3 4 11 HS IS | 31 III 4 H1 Player Ben, enter your guess Current number of correct pairs: @ Enter first card row and column, separated by space: 2 2 Open G Enter second card row and column, separated by space: 3 2 Open G Correct !!!! Updated number of correct pairs: 1 Columns Rows | 1 | 2 | 3 | 41 1 H | SISI 21 GTIT! 31 10 11 ||| | |2 1 Player Ben, enter your guess Current number of correct pairs: 1 Enter first card row and column, separated by space: 4 2 Open I Enter second card row and column, separated by space: 43 Open 1 Correct !!!! Updated number of correct pairs: 2 Columns Rows | 1 | 2 | 3 | 4 1 HIS IS 21 GITIT 31 1 G 111 41 1|IH Player Ben, enter your guess Current number of correct pairs: 2 Enter first card row and column, separated by space: 31 Open 0 Enter second card row and column, separated by space: 41 Open 0 Correct !!!! Updated number of correct pairs: 3 Columns ROWS 11213141 1 HIS IS 21 GTIT 310 G 11 4101 IHI Player Ben, enter your guess Current number of correct pairs: 3 Enter first card row and column, separated by space: 21 Open v Enter second card row and column, separated by space: 33 Open v Correct !!!! Updated number of correct pairs: 4 Game ends! Columns ROWS | 1 | 2 3 | 41 1 HS 1151 21 VIGTITI 310 | G | VI 41 0 1 |I|H Winners with 4 matched pairs: Ben Play again? an empty string to play again: Enter game level(1 to 2): 2 Enter grid size(2 to 7): Please enter a valid grid size Enter grid size(2 to 7): Please enter a valid grid size Enter grid size(2 to 7): 3 *** Cheat Sheet *** Columns Rows | 1 | 2131 11 W EPI 21 KW 101 31 KO NIL *** End Cheat Sheet *** Starting new game Columns Rows | 1 | 2 | 3 11 I 21 || 31 I INIL Player Ben, enter your guess Current number of correct pairs: 0 Enter first card row and column, separated by space: 3 3 Please choose a different row and column that is not for NIL Enter first card row and column, separated by space: -1 -1 Please choose a card row and column within the grid Enter first card row and column, separated by space: 21 Open K Enter second card row and column, separated by space: 3 1 Open K Correct !!!! Updated number of correct pairs: 1 Columns ROWS 1 2 3 11 11 2K | 31 K! INIL Player Ben, enter your guess Current number of correct pairs: 1 Enter first card row and column, separated by space: 1 2 Open E Enter second card row and column, separated by space: 1 3 Open P Non-matching. No update Columns Rows | 1 | 231 21 K 31 K NIL Player Cindy, enter your guess Current number of correct pairs: Enter first card row and column, separated by space: 21 Please choose a card that is not face up yet Enter first card row and column, separated by space: 22 Open W Enter second card row and column, separated by space: 11 Open W Correct !!!! Updated number of correct pairs: 1 Columns Rows 1231 11 W 21 KW 31 KINILI Player Cindy, enter your guess Current number of correct pairs: 1 Open P Enter first card row and column, separated by space: 23 Open 0 Enter second card row and column, separated by space: 13 Non-matching. No update Columns ROWS| 1 231 11 WII 2 KW 31 K! INILI Player Alan, enter your guess Current number of correct pairs: 2 Enter first card row and column, separated by space: 23 Open 0 Enter second card row and column, separated by space: 3 2. Open 0 Correct !!!! Updated number of correct pairs: 1 Remaining two cards are non-matching: E and P Game ends! Columns Rows | 1 | 2 | 31 11 WIEPI 21 KW 101 31 KO NIL Winners with 1 matched pairs: Alan, Ben, Cindy Play again? an empty string to play again: n Memory Game terminating

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

Logic In Databases International Workshop Lid 96 San Miniato Italy July 1 2 1996 Proceedings Lncs 1154

Authors: Dino Pedreschi ,Carlo Zaniolo

1st Edition

3540618147, 978-3540618140

More Books

Students also viewed these Databases questions

Question

e

Answered: 1 week ago

Question

=+6. What is the education level of your key public?

Answered: 1 week ago