Question: Complete in Python In Ship, Captain, and Crew, players have a cup with five dice. Each player gets three turns in which to roll a

Complete in Python

In Ship, Captain, and Crew, players have a cup with five dice. Each player gets three turns in which to roll a six (the Ship), a five (the Captain), and a four (the Crew). The first time one of these numbers is rolled, the die is removed from play. After each of those three numbers is rolled, the number of spots on two remaining dice are added up to be the player's score.

The catch is that the six, five, and four need to be rolled in order. The six needs to be rolled before or at the same time as the five. The five needs to be rolled before or at the same time as the four. If one of the lower numbers is rolled before the higher numbers, it is ignored and the player needs to go again.

If the player completes the Ship, Captain, and Crew in the first or second throw, he or she has the option to keep the score from the two remaining dice, or roll those two again to try to get a higher score. Both dice have to be thrown together one cannot be set aside while the other one is rolled.

The game can be played with any number of players and in one or many rounds. In the end, the player with the highest score wins.

Example Game 1

Roll 1: 6 6 3 1 1

Since there is a six in this roll, (the "Ship"), one of the sixes is removed. The next roll will use the four remaining dice.

Roll 2: 6 5 4 3

Since the player already rolled a six, the six in this roll does not matter. However, the player needed the five (for the Captain) and the four (for the crew). Those two dice are set aside. Now, the player has a six and a three. The player can keep those two dice, for a score of nine, or roll again to try to get a higher score. The player decides to keep the nine and not take the third roll.

Example Game 2

Roll 1: 6 5 4 3 2

This player has been very lucky and rolled a six, five, and four all in the first round. That makes the Ship, Captain, and Crew, and the two remaining dice add up to five. Because this is a low score and the player has two more turns, the player decides to take a second roll.

Roll 2: 1 1

This total score of two is very bad, so the player uses the third roll to try for a higher number of points.

Roll 3: 6 5

The six and five give a total score of eleven an excellent result.

Example Game 3

Roll 1: 4 4 3 5 2

The game requires that a six be rolled first. Since there is no six here, the player has to roll all five dice again.

Roll 2: 4 1 6 2 3

This roll gets the six, and that die is set aside. The game requires a five next, and since there is no five, the player must roll again.

Roll 3: 1 3 5 3

This roll produces the five, but there is no four. The four is required before the player can receive any points. Since there is no four in this final roll, the player gets no points because the Ship, Captain, and Crew was not completed..

Example Game 4

Roll 1: 1 2 3 4 5

There is no six, so the player must roll all five dice again.

Roll 2: 2 4 3 5 3

Again, there is no six, so the player rolls all five again.

Roll 3: 3 4 5 5 6

This roll has the six, five, and four. That lets the player take the remaining two dice (a five and a three) for the final score of eight. Since this was the third roll, the player cannot go again.

You may start with the code from this week's lecture as your base for this exercise.

Exercise 1

Write code for the basic mechanics of this game for 1 player and without user input. You should have:

  • 3 rounds
  • Keep track of whether the player has rolled a 6, 5, and 4
  • In each round, if a required number is rolled in the correct order, remove that die and mark that the required number has been rolled. For example, if it's round 1 and they roll a 6 and a 5, mark that so you know you have to look for a 4 in the next round.
  • If the user has rolled a required number, remove that die and roll only the remaining deice in the following round. For example, if it's round 1 and they roll a 6 and a 5, mark that and on round 2, you should only roll the remaining 3 dice and only look for a 4. As another example, if it's round 3 and they have rolled a 5 and 6, you should look for a 4
  • Once the 6,5,and 4 have been rolled, just print out the score on the remaining dice.
  • If you are struggling, follow this process:
    • Have 3 rounds where 5 dice are rolled every time
    • Then, check for a 6, 5, and 4 every round and print out if you see them
    • Then, keep track of whether a 6, 5, and 4 have been rolled using variables. Only print out when you see one for the first time
    • Then, only print out if you see a 5 if you have already seen a 6. Only print a 4 if you have already seen a 5.
    • Finally, update the number of dice to roll in the next round based on which required numbers you have already seen

Please comment and explain code. Thank you

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!