Solved: Write a program that allows a single Player (the user) to play a simple three dice game of chance against “The Odds”.

$30.00

Category:

Description

Solved: Write a program that allows a single Player (the user) to play a simple three dice game of chance against “The Odds”.

Write a program that allows a single Player (the user) to play a simple three dice game of chance against “The Odds”.

There is a single player, with three (12 sided) dice.

The sides of each die are labeled with the numbers from 1 to 12, 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 three dice – you may use randi()

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:

A Triple is when all the dice have the same number on their top faces. If the player has any Triple then they win the round.

A Straight is when the numbers on the three dice faces can be arranged to form a consecutive sequence like 1 2 3 or 3 4 5 If the player has any Straight then they win the round.

A Pair is when any (exactly) two dice have the same number on their top faces:

If the player’s Pair is 7’s or higher, then they win the round.

If the player’s Pair is 6 ‘s or lower, then they lose the round.

A Junker is then anything that is not a Triple, a Straight or a Pair. If the player has anyJunker then they lose the round.

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, 12], 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

Next the outcome of your roll will

be determined:

any Triple and you Win

any Straight and you Win

any Pair (7 and higher) and you Win

any Pair (6 and lower) and you Lose

anything else and you Lose

————————————-

Player

———-

12 1 9

Sorry, you lose!

Do you wish to play again [y, n] : 5

Do you wish to play again [y, n] : yes

Do you wish to play again [y, n] : y

Player

———-

8 8 8

Congrats, you win!

Do you wish to play again [y, n] : y

Player

———-

6 6 4

Sorry, you lose!

Do you wish to play again [y, n] : y

Player

———-

7 10 7

Congrats, you win!

Do you wish to play again [y, n] : y

Player

——–

1 3 2

Congrats, you win!

Do you wish to play again [y, n] : n

Computer Dice Results

———————

You played 5 rounds

Rounds won :3

Rounds lost:2

 


error: Content is protected !!