I am working on a dice project that requires players to roll the number of the corresponding round. I have pictures demonstrating what I have compelted so far. I need to incorporate a trial counter to determine how many rolls it takes for a player to roll the number corresponding to the round. I also have these three tasks and do not know how to incorporate them into the script. Thank you. ● Store a win for Player 1 or Player 2 after each round (indicate a win by a 1 and a loss by a 0). ● Store the cumulative wins of each player after each round (“P1Wins_Talley” and “P2Wins_Talley”). ● Store the overall game results in a matrix called “store_results”.  Column 1 lists the round number, Column 2 lists the total number of trials in that round, Column 3 records which player won that round (1 or 2), Column 4 records the value of Dice 1, Column 5 records the value of Dice 2, Column 6 records the sum of the two dice at the end of that round (which should equal the value in Column 1)

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

I am working on a dice project that requires players to roll the number of the corresponding round. I have pictures demonstrating what I have compelted so far. I need to incorporate a trial counter to determine how many rolls it takes for a player to roll the number corresponding to the round. I also have these three tasks and do not know how to incorporate them into the script. Thank you.

● Store a win for Player 1 or Player 2 after each round (indicate a win by a 1 and a loss by a 0).

● Store the cumulative wins of each player after each round (“P1Wins_Talley” and “P2Wins_Talley”).

● Store the overall game results in a matrix called “store_results”.  Column 1 lists the round number, Column 2 lists the total number of trials in that round, Column 3 records which player won that round (1 or 2), Column 4 records the value of Dice 1, Column 5 records the value of Dice 2, Column 6 records the sum of the two dice at the end of that round (which should equal the value in Column 1)

%Dice Game Simulation
while r <= round_total
end
%Roll the die for each player
P1_roll = randi (6,2,6);
P2_roll = randi (6,2,6);
%Determine who wins each round
if Pl_roll == r
P1Wins (r) P1Wins(r) + 1;
elseif P2_roll == r
P2Wins (r)
P2Wins (r) + 1;
end
=
end
%Player 1 wins the round, and increases the win count by ar
%Player 2 wins the round, and increases the win count by ar
%Continue to the next round or end the dice game simulation
if r == round_total %Final round of the dice game
break;
elseif PlWins(r) > round_total/2 || P2Wins (r) > round_total/2 %Player 1 or Player 2 has wo
break;
else %Continue to the next round of the game
r = r + 1;
Transcribed Image Text:%Dice Game Simulation while r <= round_total end %Roll the die for each player P1_roll = randi (6,2,6); P2_roll = randi (6,2,6); %Determine who wins each round if Pl_roll == r P1Wins (r) P1Wins(r) + 1; elseif P2_roll == r P2Wins (r) P2Wins (r) + 1; end = end %Player 1 wins the round, and increases the win count by ar %Player 2 wins the round, and increases the win count by ar %Continue to the next round or end the dice game simulation if r == round_total %Final round of the dice game break; elseif PlWins(r) > round_total/2 || P2Wins (r) > round_total/2 %Player 1 or Player 2 has wo break; else %Continue to the next round of the game r = r + 1;
%Player 1 or Player 2 wins the round if the player rolls the dice and
%scores the number of the round
%Prompt the user to enter the number of sides of the die
numsides =
input('Enter the number of sides: ');
%Calculate the number of rounds based on the number of sides of the die
min_sum = 2 %Minimum sum of two die
max_sum = 2*numsides %Maximum sum of two die
round_total = (max_sum min_sum) + 1%Formula for round total depending on # of sides on die
%Initalize the variables for "P","r", and "t"
P = 1; %P represents Player; player 1 is represented by 1, while player 2 is represented by 2
r = 2; %Round counter begins at round 2 and ends at round 12 (11 total rounds)
t = 1; %Trial counter begins at trial 1
%Initalize the matrices for player wins
round_total 11; %There is a total of 11 rounds for a six-sided die (determined from calculat
P1Wins = zeros (1, round_total); %Creates a row vector with 11 segments, that is set at 0 (playe
P2Wins = zeros (1, round_total); %Creates a row vector with 11 segments, that is set at 0 (playe
Transcribed Image Text:%Player 1 or Player 2 wins the round if the player rolls the dice and %scores the number of the round %Prompt the user to enter the number of sides of the die numsides = input('Enter the number of sides: '); %Calculate the number of rounds based on the number of sides of the die min_sum = 2 %Minimum sum of two die max_sum = 2*numsides %Maximum sum of two die round_total = (max_sum min_sum) + 1%Formula for round total depending on # of sides on die %Initalize the variables for "P","r", and "t" P = 1; %P represents Player; player 1 is represented by 1, while player 2 is represented by 2 r = 2; %Round counter begins at round 2 and ends at round 12 (11 total rounds) t = 1; %Trial counter begins at trial 1 %Initalize the matrices for player wins round_total 11; %There is a total of 11 rounds for a six-sided die (determined from calculat P1Wins = zeros (1, round_total); %Creates a row vector with 11 segments, that is set at 0 (playe P2Wins = zeros (1, round_total); %Creates a row vector with 11 segments, that is set at 0 (playe
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps

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

I am still a little confused on the setup for implementing the matrice for the store results. Is each step listed above a different method of completing the script? I am lost on how to put everything together regarding the matrice and keeping track of the trials and rounds

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Probability Problems
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education