Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a MATLAB program to simulate the Tenzi party game automatically that can P

ID: 3872070 • Letter: W

Question

Write a MATLAB program to simulate the Tenzi party game automatically that can Play Tenzi for multiple players simultaneously and automatically Ask the game host to input how many players will play 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 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. Print all the dice values on screen and clearly indicate which player (i.e. player 1, player 2, and so on...) rolls what values. 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 1. 2. 3. 4. 5. 6. 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 Print the face values of the dice that are set aside on screen for all the players Roll the remaining dice by generating as many random integers between 1 and 6 as needed for all the players. 8. 9. 10. Print the remaining dice values on screen for all the players and clearly indicate 11. Set aside the dice with the desired value (determined in step 6) and print "the 12. Print the face values of the dice that are set aside on screen for all the players which player (i.e. player 1, player 2, and so on...) rolls what values total number of dice on the side" for every player in the command window 13. Keep rolling the remaining dice until one of the players gets ten (10) dice of the 14. Track the number of rounds the players roll dice and print the round number in the 15. Print which player shouts out "TENZI" on screen same number. command window

Explanation / Answer

match = 0;
val = [];
% generate a vector with random 10 numbers
for i=1:10
val(i) = (randi(6));
end
% ask user input
prompt = "Enter number:";
x = input(prompt);
while(match<10)
disp(val);
t1 = length(val);
val = val(val~=x);
t2 = length(val);
% get absolute value of number of elements deleted and add it to match
if(t1<t2)
match = match + t2 - t1;
elseif(t1>t2)
match = match + t1 - t2;
end
fprintf("The total number of dice on the side :%d ",match);
% roll remaining dice
for i=1:t2
val(i) = (randi(6));
end
end
disp('Tenzi');

% --------------- End of Program -------------------------

% sample output

Enter number: 5

5 6 6 2 6 5 3 2 6 4
The total number of dice on the side :2
4 1 2 2 3 2 5 5
The total number of dice on the side :4
5 5 6 5 6 2
The total number of dice on the side :7
2 3 3
The total number of dice on the side :7
1 4 4
The total number of dice on the side :7
4 4 6
The total number of dice on the side :7
5 5 6
The total number of dice on the side :9
3
The total number of dice on the side :9
3
The total number of dice on the side :9
1
The total number of dice on the side :9
2
The total number of dice on the side :9
2
The total number of dice on the side :9
6
The total number of dice on the side :9
4
The total number of dice on the side :9
1
The total number of dice on the side :9
6
The total number of dice on the side :9
6
The total number of dice on the side :9
1
The total number of dice on the side :9
1
The total number of dice on the side :9
5
The total number of dice on the side :10
Tenzi

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote