Simulate the game by using the round and trial counters you have established. ● 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”). I am trying to simulate a dice rolling game where players compete to roll two six-sided die and try to get the value based on the round number. For eample if it is round 2, the players are trying to roll snake eyes. I have submitted a file of what I have so far. Not sure if I should begin the simulation with a loop or while and if statments. How should I approach the simulation? Thank you.

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter8: Advanced Data Handling Concepts
Section: Chapter Questions
Problem 10PE
icon
Related questions
Question
100%

Simulate the game by using the round and trial counters you have established.

● 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”).

I am trying to simulate a dice rolling game where players compete to roll two six-sided die and try to get the value based on the round number. For eample if it is round 2, the players are trying to roll snake eyes. I have submitted a file of what I have so far. Not sure if I should begin the simulation with a loop or while and if statments. How should I approach the simulation? Thank you. 

clear all
close all
clc
%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 = 1; %Round counter begins at round 1
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:clear all close all clc %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 = 1; %Round counter begins at round 1 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 3 steps with 4 images

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

Thank you so much. One final question I have is similar to the round counter, can i make a trial counter to count the amount of rolls it takes until a player reaches the target. 

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
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr