**Frenetic Dice Game **

Tenzi Party

Tenziis a frenetic dice game that is a fun party activity. The game uses sets of ten (10) 6-sided

dice to play. Each player holds 10 dice in hands. When the game starts, everyone rolls at the

same time. Each player looks at the first roll and decides which number to roll all 10 dice to

become. For example, if the first roll shows more 3’s than any other number, it’s logical to go

for all 3s. Put all the dice with the number aside and quickly roll the remaining dice. Keep

rolling until all 10 dice show the same number. The goal of the game is to roll fast and be the

first player to get all 10 of the dice to show the same number. The first player that shouts

“TENZI” wins the game.

The following link contains the detail game description:

http://zenomath.org/wp-content/uploads/2015/02/Zeno-Family-Math-Game-TENZI.pdf

Write a MATLAB program to simulate the Tenzi party game automatically that can:**
**1. Play Tenzi for multiple players simultaneously and automatically.

**2. Ask the game host to input how many players will play.**

**3. Use ten (10) 6-sided dice to automatically play the Tenzi game for each player. For**

**example, 4 players will use a total of forty (40) dice.**

**4. Generate ten (10) random integers between 1 and 6 to represent the face value of**

**rolling ten dice for each player to simulate all players roll at the same time. For**

**example, a 6-player game will generate 60 random integers.**

**5. Print all the dice values on screen and clearly indicate which player (i.e. player 1,**

**player 2, and so on…) rolls what values.**

**6. Based on the first roll results, the program should automatically decide the best**

**numbers to keep for all the players. The program should be able to automatically**

**keep different dice values best for each player. The program must be able to make**

**the best decisions without bias for all the players.**

**7. Set aside the dice rolled with the number by counting and printing “the number of**

**dice on the side” for all the players in the command window.**

**8. Print the face values of the dice that are set aside on screen for all the players.**

**9. Roll the remaining dice by generating as many random integers between 1 and 6**

**as needed for all the players.**

**10. Print the remaining dice values on screen for all the players and clearly indicate**

**which player (i.e. player 1, player 2, and so on…) rolls what values.**

**11. Set aside the dice with the desired value (determined in step 6) and print “the**

**total number of dice on the side” for every player in the command window.**

**12. Print the face values of the dice that are set aside on screen for all the players.**

**13. Keep rolling the remaining dice until one of the players gets ten (10) dice of the**

**same number.**

**14. Track the number of rounds the players roll dice and print the round number in the**

**command window.**

**15. Print which player shouts out “TENZI” on screen.**

The finished program can look like the following example. Extra components are always welcome.

How many players will play together? 2**
**Round 1:

Player 1 rolls: 6 6 2 6 2 3 4 3 3 3

Player 2 rolls: 6 1 1 6 6 6 6 2 2 1

Player 1 moves value 3 to the side

Player 2 moves value 6 to the side

Player 1 has 4 dice on the side

Player 2 has 5 dice on the side

Player 1 side: 3 3 3 3

Player 2 side: 6 6 6 6 6

Round 2:

Player 1 rolls: 2 1 6 4 2 5

Player 2 rolls: 2 5 2 4 3

Player 1 has 4 dice on the side

Player 2 has 5 dice on the side

Player 1 side: 3 3 3 3

Player 2 side: 6 6 6 6 6

Round 3:

Player 1 rolls: 3 5 4 6 6 4

Player 2 rolls: 1 2 2 3 3

Player 1 has 5 dice on the side

Player 2 has 5 dice on the side

Player 1 side: 3 3 3 3 3

Player 2 side: 6 6 6 6 6

Round 4:

Player 1 rolls: 4 4 1 5 1

Player 2 rolls: 5 6 1 1 5

Player 1 has 5 dice on the side

Player 2 has 6 dice on the side

Player 1 side: 3 3 3 3 3

Player 2 side: 6 6 6 6 6 6

Round 5:

Player 1 rolls: 1 6 6 1 2

Player 2 rolls: 6 4 4 1

Player 1 has 5 dice on the side

Player 2 has 7 dice on the side

Player 1 side: 3 3 3 3 3

Player 2 side: 6 6 6 6 6 6 6

Round 6:

Player 1 rolls: 2 6 6 2 2

Player 2 rolls: 6 5 5

Player 1 has 5 dice on the side

Player 2 has 8 dice on the side

Player 1 side: 3 3 3 3 3

Player 2 side: 6 6 6 6 6 6 6 6

Round 7:

Player 1 rolls: 6 3 1 2 1

Player 2 rolls: 4 1

Player 1 has 6 dice on the side

Player 2 has 8 dice on the side

Player 1 side: 3 3 3 3 3 3

Player 2 side: 6 6 6 6 6 6 6 6

Round 8:

Player 1 rolls: 6 4 4 5

Player 2 rolls: 3 4

Player 1 has 6 dice on the side

Player 2 has 8 dice on the side

Player 1 side: 3 3 3 3 3 3

Player 2 side: 6 6 6 6 6 6 6 6

Round 9:

Player 1 rolls: 6 6 6 2

Player 2 rolls: 1 4

Player 1 has 6 dice on the side

Player 2 has 8 dice on the side

Player 1 side: 3 3 3 3 3 3

Player 2 side: 6 6 6 6 6 6 6 6

Round 10:

Player 1 rolls: 3 5 2 3

Player 2 rolls: 2 2

Player 1 has 8 dice on the side

Player 2 has 8 dice on the side

Player 1 side: 3 3 3 3 3 3 3 3

Player 2 side: 6 6 6 6 6 6 6 6

Round 11:

Player 1 rolls: 1 4

Player 2 rolls: 6 1

Player 1 has 8 dice on the side

Player 2 has 9 dice on the side

Player 1 side: 3 3 3 3 3 3 3 3

Player 2 side: 6 6 6 6 6 6 6 6 6

Round 12:

Player 1 rolls: 3 4

Player 2 rolls: 6

Player 1 has 9 dice on the side

Player 2 has 10 dice on the side

Player 1 side: 3 3 3 3 3 3 3 3 3

Player 2 side: 6 6 6 6 6 6 6 6 6 6

Round 13:

Player 1 rolls: 1

Player 2 rolls:

*** Player 2 yells TENZI!!! ***

Here is another example.

How many players will play together? 4

**Round 1:**

Player 1 rolls: 1 2 5 2 2 3 2 2 2 6

Player 2 rolls: 3 1 1 1 3 6 1 6 1 1

Player 3 rolls: 5 3 5 4 3 4 2 4 2 2

Player 4 rolls: 5 2 3 5 2 2 4 3 2 2

Player 1 moves value 2 to the side

Player 2 moves value 1 to the side

Player 3 moves value 2 to the side

Player 4 moves value 2 to the side

Player 1 has 6 dice on the side

Player 2 has 6 dice on the side

Player 3 has 3 dice on the side

Player 4 has 5 dice on the side

Player 1 side: 2 2 2 2 2 2

Player 2 side: 1 1 1 1 1 1

Player 3 side: 2 2 2

Player 4 side: 2 2 2 2 2

Round 2:

Player 1 rolls: 4 5 4 2

Player 2 rolls: 2 1 2 2

Player 3 rolls: 3 3 2 1 1 4 4

Player 4 rolls: 5 5 2 4 6

Player 1 has 7 dice on the side

Player 2 has 7 dice on the side

Player 3 has 4 dice on the side

Player 4 has 6 dice on the side

Player 1 side: 2 2 2 2 2 2 2

Player 2 side: 1 1 1 1 1 1 1

Player 3 side: 2 2 2 2

Player 4 side: 2 2 2 2 2 2

Round 3:

Player 1 rolls: 5 6 4

Player 2 rolls: 1 6 1

Player 3 rolls: 6 1 3 1 1 5

Player 4 rolls: 4 4 2 6

Player 1 has 7 dice on the side

Player 2 has 9 dice on the side

Player 3 has 4 dice on the side

Player 4 has 7 dice on the side

Player 1 side: 2 2 2 2 2 2 2

Player 2 side: 1 1 1 1 1 1 1 1 1

Player 3 side: 2 2 2 2

Player 4 side: 2 2 2 2 2 2 2

Round 4:

Player 1 rolls: 6 3 2

Player 2 rolls: 5

Player 3 rolls: 6 1 5 4 2 3

Player 4 rolls: 5 5 3

Player 1 has 8 dice on the side

Player 2 has 9 dice on the side

Player 3 has 5 dice on the side

Player 4 has 7 dice on the side

Player 1 side: 2 2 2 2 2 2 2 2

Player 2 side: 1 1 1 1 1 1 1 1 1

Player 3 side: 2 2 2 2 2

Player 4 side: 2 2 2 2 2 2 2

Round 5:

Player 1 rolls: 5 1

Player 2 rolls: 4

Player 3 rolls: 4 6 6 4 5

Player 4 rolls: 5 5 2

Player 1 has 8 dice on the side

Player 2 has 9 dice on the side

Player 3 has 5 dice on the side

Player 4 has 8 dice on the side

Player 1 side: 2 2 2 2 2 2 2 2

Player 2 side: 1 1 1 1 1 1 1 1 1

Player 3 side: 2 2 2 2 2

Player 4 side: 2 2 2 2 2 2 2 2

Round 6:

Player 1 rolls: 6 6

Player 2 rolls: 4

Player 3 rolls: 1 3 2 2 4

Player 4 rolls: 3 2

Player 1 has 8 dice on the side

Player 2 has 9 dice on the side

Player 3 has 7 dice on the side

Player 4 has 9 dice on the side

Player 1 side: 2 2 2 2 2 2 2 2

Player 2 side: 1 1 1 1 1 1 1 1 1

Player 3 side: 2 2 2 2 2 2 2

Player 4 side: 2 2 2 2 2 2 2 2 2

Round 7:

Player 1 rolls: 3 6

Player 2 rolls: 5

Player 3 rolls: 1 5 5

Player 4 rolls: 3

Player 1 has 8 dice on the side

Player 2 has 9 dice on the side

Player 3 has 7 dice on the side

Player 4 has 9 dice on the side

Player 1 side: 2 2 2 2 2 2 2 2

Player 2 side: 1 1 1 1 1 1 1 1 1

Player 3 side: 2 2 2 2 2 2 2

Player 4 side: 2 2 2 2 2 2 2 2 2

Round 8:

Player 1 rolls: 3 5

Player 2 rolls: 2

Player 3 rolls: 5 1 4

Player 4 rolls: 3

Player 1 has 8 dice on the side

Player 2 has 9 dice on the side

Player 3 has 7 dice on the side

Player 4 has 9 dice on the side

Player 1 side: 2 2 2 2 2 2 2 2

Player 2 side: 1 1 1 1 1 1 1 1 1

Player 3 side: 2 2 2 2 2 2 2

Player 4 side: 2 2 2 2 2 2 2 2 2

Round 9:

Player 1 rolls: 1 5

Player 2 rolls: 4

Player 3 rolls: 1 2 3

Player 4 rolls: 1

Player 1 has 8 dice on the side

Player 2 has 9 dice on the side

Player 3 has 8 dice on the side

Player 4 has 9 dice on the side

Player 1 side: 2 2 2 2 2 2 2 2

Player 2 side: 1 1 1 1 1 1 1 1 1

Player 3 side: 2 2 2 2 2 2 2 2

Player 4 side: 2 2 2 2 2 2 2 2 2

Round 10:

Player 1 rolls: 3 4

Player 2 rolls: 1

Player 3 rolls: 4 1

Player 4 rolls: 6

Player 1 has 8 dice on the side

Player 2 has 10 dice on the side

Player 3 has 8 dice on the side

Player 4 has 9 dice on the side

Player 1 side: 2 2 2 2 2 2 2 2

Player 2 side: 1 1 1 1 1 1 1 1 1 1

Player 3 side: 2 2 2 2 2 2 2 2

Player 4 side: 2 2 2 2 2 2 2 2 2

Round 11:

Player 1 rolls: 1 3

Player 2 rolls:

Player 3 rolls: 5 2

Player 4 rolls: 1

*** Player 2 yells TENZI!!! ***

Here is another example.

How many players will play together? 0

**Round 1:**

*** Player yells TENZI!!! ***

**Solution**** **

rolls=randi(6,1,10);

fprintf(‘Roll:\t’)

for i=1:length(rolls)

fprintf(‘%d\t’, rolls(i));

end

N=input(‘\nEnter which number do you want to keep on the side? ‘);

Ncount=0;

whileisempty(rolls)==0

Ncount=Ncount+sum(rolls==N);

fprintf(sprintf([‘There are ‘ num2str(Ncount) ‘ dice on the side\n’]));

fprintf(‘Side:\t’);

for i=1:Ncount

fprintf(‘%d\t’, N);

end

rolls=randi(6,1,10-Ncount);

fprintf(‘\nRoll:\t’);

for i=1:length(rolls)

fprintf(‘%d\t’, rolls(i));

end

fprintf(‘\n’);

end

fprintf(‘\n*** TENZI!!! ***\n\n’);