I need to calculate the number of trials per round (11 total rounds) it takes for player 2, or player 1 to roll to die that add up to the corresponding round. For example, if it is round three, the player must roll a 2 and a 1. I need to find how many trials/rolls it takes per round to get the specific value to graph on a bar graph. How can I incorporate in my code something to track how many rolls/trials per round. Thank you. I provided my code below aswell.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

I need to calculate the number of trials per round (11 total rounds) it takes for player 2, or player 1 to roll to die that add up to the corresponding round. For example, if it is round three, the player must roll a 2 and a 1. I need to find how many trials/rolls it takes per round to get the specific value to graph on a bar graph. How can I incorporate in my code something to track how many rolls/trials per round. Thank you. I provided my code below aswell.

unu counce begins
trial_counter
=
=
%Initalize the matrices for player wins
round_total
11; %There is a total of 11 rounds for a six-sided die (d
P1Wins = zeros (1, round_total); %Creates a row vector with 11 segments,
P2Wins = zeros (1,round_total); %Creates a row vector with 11 segments,
%Dice Game Simulation
while r <= round_total
diel
randi (6); %roll of first die
die2 = randi (6); %roll of second die
P1_roll diel + die2
=
0; %Trial counter begins at trial 0
trial_counter = trial_counter + 1;
diel = randi (6)
die2 = randi (6)
P2_roll diel + die2
trial counter
=
trial counter + 1;
Transcribed Image Text:unu counce begins trial_counter = = %Initalize the matrices for player wins round_total 11; %There is a total of 11 rounds for a six-sided die (d P1Wins = zeros (1, round_total); %Creates a row vector with 11 segments, P2Wins = zeros (1,round_total); %Creates a row vector with 11 segments, %Dice Game Simulation while r <= round_total diel randi (6); %roll of first die die2 = randi (6); %roll of second die P1_roll diel + die2 = 0; %Trial counter begins at trial 0 trial_counter = trial_counter + 1; diel = randi (6) die2 = randi (6) P2_roll diel + die2 trial counter = trial counter + 1;
it Pl_roll == r
PlWins (r) = 1;
elseif P2_roll
else
PlWins Talley = cumsum (P1Wins)
r = r + 1
end
end
== r
P2Wins (r)
1;
P2Wins Talley = cumsum (P2Wins)
r = r + 1
while Pl_roll N= r || P2_roll
end
diel randi (6); %roll of first die
die2 = randi(6); %roll of second die
P1_roll diel + die2
trial_counter
trial_counter + 1;
=
diel
randi (6)
die2 = randi (6)
P2_roll
trial_counter
diel + die2
WE P
=
trial_counter + 1;
Transcribed Image Text:it Pl_roll == r PlWins (r) = 1; elseif P2_roll else PlWins Talley = cumsum (P1Wins) r = r + 1 end end == r P2Wins (r) 1; P2Wins Talley = cumsum (P2Wins) r = r + 1 while Pl_roll N= r || P2_roll end diel randi (6); %roll of first die die2 = randi(6); %roll of second die P1_roll diel + die2 trial_counter trial_counter + 1; = diel randi (6) die2 = randi (6) P2_roll trial_counter diel + die2 WE P = trial_counter + 1;
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 4 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

This is very helpful thank you. However, when I run the code, only player 1 wins every round. Player 2 is not accounted for. How do I fix this?

Solution
Bartleby Expert
SEE SOLUTION
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY