Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python 3.6- I've created dice playing game where it's the player versus the computer. This is the part I need help with (the two rules

Python 3.6-

I've created dice playing game where it's the player versus the computer. This is the part I need help with (the two rules - please provide indented source code. Thanks) :

If you wish, you may conclude your turn, and keep the points. Or you may choose to roll again. But if you do roll again, you must score points on the next roll. If you do, those points are added to what you already have. If you roll again and dont score any points you have Wimped Out. Your turn is over and you lose all points for that turn.

As long as your turn hasnt ended, you get another chance to roll again if you want to, subject to the same rules.

The You May Not Want To But You Must rule states that you must roll again if you get all five dice scoring. You can't end your turn there.

The Futtless Rule states that if you match three dice, you must roll those dice that dont score anything again. This clearly does not include any single die that is a 5 or a 1, or the wildcard 3 on the special die.

You cannot roll the non-scoring dice and match the flash, for if you do, you must roll that die again. However, as long as you dont match the flash, one time re-rolling the non-scoring dice is sufficient. If, however, that re-roll causes all five dice to score, the You May Not Want To rule comes into effect.

_____________________________________________________________________

This is the part I've fulfilled:

Equipment -- five dice, one of which is special. If playing with actual dice, one would use, say four white dice and one red die. In simulating dice rolls in a computer program, just keep track of which one of the dice is the special one. To take a turn, a player rolls all five dice, and scores them as follows. If you roll:

five 2's = 200 points five 4's = 400 points five 5's = 500 points five 6's = automatically win the game five 1's = automatically lose the game

(these are known as a freight train, but see the You Have To rule, below) three 2's = 20 points three 3's = 30 points three 4's = 40 points three 5's = 50 points three 6's = 60 points three 1's = 100 points

(these are each known as a flash) if you don't score any of the above, for each die that comes up 5 you get five points, and for each die

that comes up 1 you get ten points. If you get a flash other than 5s or 1s you also count the individual dice that come up 5 or 1 for five or ten points, respectively.

On top of that, the special dies 3 is a wild card. Whenever a 3 comes up on that die, it can be combined with any the other dices faces to complete a three of a kind (a flash). A wild card cannot be used to complete a five of a kind (a freight train). If that doesn't work, all by itself it could be counted as a 5 (for five points) or a 1 (for ten points).

When it is your turn, you roll all of the dice, figure up your score, and you get that many points.

_________________________________________________________________

Here's my source code:

import random def rollDice(): roll_again = input("Roll the dice again? ") global roll_List roll_List = [] if roll_again == "yes" or "y": for i in range(4): white_Dice = random.randint(1, 6) roll_List.append(white_Dice) global red_Dice red_Dice = random.randint(1, 6) # checking for wildcard and altering the value # in the list accordingly if (red_Dice == 3): if (roll_List.count(4) is 2): roll_List[roll_List.index(1)] = 4 if (roll_List.count(5) is 2): roll_List[roll_List.index(2)] = 5 if (roll_List.count(6) is 2): roll_List[roll_List.index(3)] = 6 else: roll_List.append(red_Dice) print(roll_List) rollDice() def freightTrain(): global freight_Train_points freight_Train_points = 0 if roll_List.count(5) is 5: freight_Train_points += 500 if roll_List.count(4) is 5: freight_Train_points += 400 if roll_List.count(2) is 5: freight_Train_points += 200 if roll_List.count(6) is 5: print("You've won the game!") if roll_List.count(1) is 5: print("You lose the game!") print("Freight train points are: ", freight_Train_points) if freight_Train_points > 0: print("You May Not Want To But You Must Roll Again!") freightTrain() def flash(): global flash_points flash_points = 0 if roll_List.count(6) is 3: flash_points += 60 if roll_List.count(5) is 3: flash_points += 50 if roll_List.count(4) is 3: flash_points += 40 if roll_List.count(3) is 3: flash_points += 30 if roll_List.count(2) is 3: flash_points += 20 if roll_List.count(1) is 3: flash_points += 100 print("Flash points are: ", flash_points) flash() # calculating the score other than flas and freight def scoreCalc(): if (flash_points == 0 and freight_Train_points == 0): other_Score = 0 other_Score += roll_List.count(1) * 10 other_Score += roll_List.count(5) * 5 print("Score other than flash and freight is : ", other_Score) scoreCalc() 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases

Authors: Ian Robinson, Jim Webber, Emil Eifrem

1st Edition

1449356265, 978-1449356262

More Books

Students also viewed these Databases questions