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.
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...
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;](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F6ad46b3e-a02f-4382-8de1-0ec501356244%2F82c063ee-e0ab-4b04-bdca-46abe3584e26%2Fnxldysq_processed.png&w=3840&q=75)
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;](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F6ad46b3e-a02f-4382-8de1-0ec501356244%2F82c063ee-e0ab-4b04-bdca-46abe3584e26%2F7x0o0t7h_processed.png&w=3840&q=75)
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
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 4 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
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
Recommended textbooks for you
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
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…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
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)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
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…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
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)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
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](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY