Question
MATLAB Program Game Specification: Write a program that allows a single Player (the user) to play a simple four dice game of chance against The
MATLAB Program
Game Specification:
Write a program that allows a single Player (the user) to play a simple four dice game of chance against "The Odds".
There is a single player, with four six sided die.
The sides of each die are labeled with the numbers from 1 to 6, we will call this the value of the die.
A game is made up of rounds, a single round is played as such:
The player rolls their four dice you may use randi()
The dice are displayed, in some reasonable format.
The user is given the option to re-roll (up to two of their dice) and specify exactly which die they wish to re-roll.
The dice are displayed, in some reasonable format.
A determination is made as to whether or not the player won the round, this determination is made via the following rules:
i.A Quad is when all the dice have the same number on their top faces. If the player has any Quad then they receive 108 "win"s
ii.A Triple is when exactly three of the dice have the same number on their top faces. If the player has any Triple then they receive 6 "win"s
iii.A Two-Pair is when exactly two dice have the number n1 on their top faces, exactly two dice have the number n2 on their top faces, and n1 is not equal to n2. If the player has any Two-Pair then they receive 4 "win"s
iv.A Junker is then anything that is not listed above. If the player has any Junker then they they receive 1 "lose"
The result of the round (with respect to the Player) is reported.
The player is asked if they wish to play another round.
Once the player indicates that they do not wish to play another round: Before exiting, the program displays a short report stating how many rounds were played, of those - how many were won and how many were lost.
Outline:
Create a MATLAB Script .m file
Write the necessary MATLAB commands to meet the game specification given above
Make sure to test your program when it is done
You really need to run your program a number of time to do this thoroughly
Notes(s):
You will need to use the
= randi( [1, 6], 1 );
to assign a random die roll value.
Your Script will be many lines long
Sample Run(s):
Welcome to Computer Dice
-------------------------------------
You will first roll your dice
You then are allowed to re-roll upto
two of your dice
Finally the outcome of your roll is
be determined:
any Quad and you receive 108 Wins
any Triple and you receive 6 wins
any Two-Pair and you receive 4 Wins
anything else and you receive 1 Lose
-------------------------------------
Player
----------
1 6 2 4
Please enter the number of diceto re-roll [0, 2] : 2
Please enter the number of the die to re-roll [1, 4] : 1
Please enter the number of the die to re-roll [1, 4] : 3
Player
----------
2 6 6 4
Junker - Sorry, you lose!
Do you wish to play again [y, n] : y
Player
----------
4 6 6 5
Please enter the number of diceto re-roll [0, 2] : 2
Please enter the number of the die to re-roll [1, 4] : 1
Please enter the number of the die to re-roll [1, 4] : 4
Player
----------
3 6 6 2
Junker - Sorry, you lose!
Do you wish to play again [y, n] : y
Player
----------
3 4 6 6
Please enter the number of diceto re-roll [0, 2] : 2
Please enter the number of the die to re-roll [1, 4] : 1
Please enter the number of the die to re-roll [1, 4] : 2
Player
----------
6 6 6 6
Quad - Congrats, you win!
Do you wish to play again [y, n] : n
Computer Dice Results
---------------------
You played 3 rounds
Wins :108
Loses :2
---------------------
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