% Initalize the variables for "t" and "r" r = 2; %Round counter begins at round 2 and ends at round 12 (11 total rounds) t = 0; %Initialize the trial counter (Starts at 0) p = 1; %Player 1 is represented by 1 and player 2 is represented by 2 %Initalize the matrices for player wins and trial counter round_total = 11; %There is a total of 11 rounds for a six-sided die (determined from calculation) P1Wins = zeros (1, round_total); %Creates a row vector with 11 segments, that is set at 0 (player 1) P2Wins = zeros (1, round_total); % Creates a row vector with 11 segments, that is set at 0 (player 2) trialsPerRound = zeros (1, round_total); % Creates a row vector with 11 segments, that is set at 0 %Dice Game Simulation while r <= round_total diel = randi (6) %Player 1 rolls the first die die2 = randi (6) %Player 2 rolls the second die P1_roll diel + die2 %The sum of the two die player 1 rolls t = t + 1; %Resets the trial counter for each new round diel randi (6) %Player 2 rolls the first die die2 = randi (6) %Player 2 rolls the second die P2_roll t = t + 1; %Increment if Pl_roll == r diel + die2 %The sum of the two die player 2 rolls the trial counter by 1 P1Wins (r) = 1; % Player 1 won the round trialsPerRound (r) = t; % Update the number of trials per round PlWins Talley = cumsum (P1Wins) %Update the cumulative wins for player r = r + 1; % Increment the round counter by 1 t = 1 %Resets the trial counter to 1 at the start of every round
% Initalize the variables for "t" and "r" r = 2; %Round counter begins at round 2 and ends at round 12 (11 total rounds) t = 0; %Initialize the trial counter (Starts at 0) p = 1; %Player 1 is represented by 1 and player 2 is represented by 2 %Initalize the matrices for player wins and trial counter round_total = 11; %There is a total of 11 rounds for a six-sided die (determined from calculation) P1Wins = zeros (1, round_total); %Creates a row vector with 11 segments, that is set at 0 (player 1) P2Wins = zeros (1, round_total); % Creates a row vector with 11 segments, that is set at 0 (player 2) trialsPerRound = zeros (1, round_total); % Creates a row vector with 11 segments, that is set at 0 %Dice Game Simulation while r <= round_total diel = randi (6) %Player 1 rolls the first die die2 = randi (6) %Player 2 rolls the second die P1_roll diel + die2 %The sum of the two die player 1 rolls t = t + 1; %Resets the trial counter for each new round diel randi (6) %Player 2 rolls the first die die2 = randi (6) %Player 2 rolls the second die P2_roll t = t + 1; %Increment if Pl_roll == r diel + die2 %The sum of the two die player 2 rolls the trial counter by 1 P1Wins (r) = 1; % Player 1 won the round trialsPerRound (r) = t; % Update the number of trials per round PlWins Talley = cumsum (P1Wins) %Update the cumulative wins for player r = r + 1; % Increment the round counter by 1 t = 1 %Resets the trial counter to 1 at the start of every round
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
Related questions
Question
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)
I provided my code below of a dice roll simulation in matlab. How do I add the matrix "store_results" into my code. Thank you.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 5 steps
Knowledge Booster
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.Recommended textbooks for you
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education