Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Consider a dice game which has the following rules: You start the game with 3 5 dice and roll them simultaneously Any dice which show
Consider a dice game which has the following rules:
You start the game with dice and roll them simultaneously
Any dice which show a or are removed. If a dice shows a you add one dice back in for your next roll.
The total of the remaining dice are then added together to give you a score for your first round using the following scoring system:
points
points
point deduction
If there was at least one removed, this will double your score for this round The same process is continued for the next round and your score is calculated again
Continue rolling until all dice have been removed
Add the total score of each round together to give you a final score
Use MATLAB whileloop and ifelse statements to create a script that calculates the total score that a single player will get in this game. You will need to generate random integers from to simulate rolling the dice. Use the skeleton code below to help you. Note that rolling a single dice times is acceptable as opposed to rolling dice
Clear all
Set: initial number of dice ie total score ie
While the number of dice left is nonzero, do the following
Start a new round
Set round score to zero, number of and s and number of also to
For : number of dice
Roll the die, getting a score between and
Count the number of s and s ie add to number of s and s
Count the number of s ie add to number of s
Count the number of s ie add to number of
Add score of this die, eg points if its points if points if to round score
End
If number of s is double round score
Add round score to total score
Subtract the number of s and s from number of dice
Add the number of s to the number of dice
End
Display total score
Can you show me how to write manually in matlab?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started