Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement this with MIPS ASSEMBLY Language Game mechanic The 21 number game The performer asks a spectator to choose a card out of a 21-deck

Implement this with MIPS ASSEMBLY Language

Game mechanic

The 21 number game

  1. The performer asks a spectator to choose a card out of a 21-deck and to memorize it.

  • Lets say the spectator selected card 6!

  • And lets assume the cards are in the performer hand in numerical order.

Hand

1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21

  1. Then, the performer distributes the cards into three columns on the table (numbered from 1 to 3) one row at a time. Starting by column 1, then 2, then 3. And repeating (1, 2, 3, 1, 2, 3, ) until all cards are placed on the table.

Col 1

Col 2

Col 3

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

  1. Once all cards are on the table, the performer asks the spectator to point to the column containing his card.

  • Card 6 is in column 3!

  1. The performer collects the cards in each column into a single pile again. This time, the collection is made a complete column at a time; making sure the column selected by the spectator is placed in the middle of the other two.

  • Assuming collection of column 1, then 3, then 2:

Hand

1, 4, 7, 10, 13, 16, 19, 3, 6, 9, 12, 15, 18, 21, 2, 5, 8, 11, 14, 17, 20

  1. The process is repeated 2 more times!

  1. Place cards on the table one row at a time:

Col 1

Col 2

Col 3

1

4

7

10

13

16

19

3

6

9

12

15

18

21

2

5

8

11

14

17

20

  1. And back to the hand one column at a time (6 is in column 3, so column 3 is collected in the middle):

Hand

1, 10, 19, 9, 18, 5, 14, 7, 16, 6, 15, 2, 11, 20, 4, 13, 3, 12, 21, 8, 17

  1. Place cards on the table one row at a time:

Col 1

Col 2

Col 3

1

10

19

9

18

5

14

7

16

6

15

2

11

20

4

13

3

12

21

8

17

  1. And back to the hand one column at a time (6 is in column 1, so column 1 is collected in the middle):

Hand

10, 18, 7, 15, 20, 3, 8, 1, 9, 14, 6, 11, 13, 21, 19, 5, 16, 2, 4, 12, 17

  1. Finally, the selected card is revealed as being the 11th card (from both ends!).

Your assignment

Your program will play the role of the performer!

  1. It begins by displaying a welcome message and an explanation of what the user should do.

  1. Then, three consecutive times:

  1. The program should place the cards in the hand into three columns, and show them to the user.

  1. Ask the user where the selected card is.

  • The user input should be validated!

  1. Based on user input, define the order columns are collected

  • Remember the column the user chose is always second.

  1. Place the cards on each column back in the hand.

  1. Let the user know which card was selected!

Example run

Welcome to the Twenty-one number

Think of a number in the interval 1-21, and memorize it!

print the column out....

In which column is your number (1, 2, 3): 4

The number you input is invalid!

In which column is your number (1, 2, 3): 3

shuffle, and print out the column 2 more times .....then

In which column is your number (1, 2, 3): 1

The number you selected was: 6

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

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions