Using random numbers and if/else statements.
Mia is a dice game where players take turns rolling a pair of dice hidden under a cup.
The first player shakes the cup, inverts it on the table, and peaks at the dice. They announce what the dice are (usually honestly) and slides the cup on to the next player.
The next player has several options, one of which it to re-roll the dice. In this case they are required to announce a better roll than the previous one. If their roll isn't better, then they have to bluff. At each step players can accept the previous roll unseen, or challenge it. If a player gets caught lying, they lose, but if an honest roll is challenged, then the challenger losses.
When announcing a roll, the higher die is always mentioned first. Higher is better, except for doubles (a matching pair) and the very best roll is 2-1 and is called Mia.
The complete rankings from lowest to highest are:
41, 42, 43,
51, 52, 53, 54,
61, 62, 63, 64, 65,
66, 55, 44, 33, 22, 11,
21 (Mia)
This description is adequate for this assignment. You can
find a more complete description of Mia's rules at: https://boardgamegeek.com/boardgame/41247/mia
Write code using Random to simulating rolling two random dice. You should get two random values from 1 to 6 and store them in variables die1 and die2. Print those variables like this:
Since it is using Random, it should get different results every time you run it. Run your program several times to make sure you can get all values from 1 to 6.
Use an if statement to compare the two dice, and, if necessary, swap the values in die1 and die2. Note: to swap 2 values you will need a third temporary variable to hold one of the values and 3 assignment statements (like: temp = a; a = b; b = temp;). Move your printing code to the end of the program and again test it several times. It should now look like this:
Our program is going to be comparing the first player's roll to the second player's roll and advising them what to do. Because of the messy ordering of which rolls are better than others, it would be rather messy code to directly compare die1 and die2 of player1 to die1 and die2 of player2. To make it easier we are going to be calculating a single composite value named rank1 that reflects the ranking rules.
1st: Combine the two die values into a single number (e.g. 4 2 would become 42). This can be done with simple math. Think about how 2 digit numbers have a 10's digit and a 1's digit.
2nd: If we have doubles, subtract that from 200 (e.g. for 3 3 the rank would be 200 - 33 = 167. This is a little weird, but it makes the best doubles 1 1 have the highest rank 189.)
3rd: If we have Mia, add 200 (e.g. 2 1 would now be 221 and is higher than everything else)
You will need to write several if statements (which is the objective of this assignment). Store this value in a variable named rank1 and print it like this:
Test your program enough times to be sure it handles all the cases.
Do the same as above for the second player. Roll 2 dice, swap them to put the highest first, calculate a composite ranking value rank2, and print your results. Your output should now look like:
Second player's roll is 3 3 rank2 = 167
Finally based on comparing the rank1 and rank2 values,
print an appropriate message to the second player advising
them if they can announce their actual roll or if they will
need to bluff.
Turn in your final code and the output from 5 runs of your finished program. At least one of these should involve doubles, and at least one should involve Mia.