Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Mahjong Scoring***IN PYTHON PLEASE*** The Japanese version of Mahjong is a four-player game with somewhat complicated scoring rules. Each player begins with a specified number

Mahjong Scoring***IN PYTHON PLEASE***

The Japanese version of Mahjong is a four-player game with somewhat complicated scoring rules. Each player begins with a specified number of points (e.g., 20,000 points). At the end of each hand, each player will gain or lose points based on the winner of that hand, according to the rules below. Complete the score() function, which takes three arguments:

An integer in the range 113 representing the Han value An integer representing the Fu value, which is either 25 or an even number in the range 20130 A Boolean value (either True or False) indicating whether the winning player was also the dealer for this hand

The function returns an integer value representing the number of points gained by the winner. For this problem, we dont care how many points each of the other players will lose, and we will simplify things by ignoring the actual mechanism of the win (by the winner drawing a tile or by one of the losing players discarding a tile).

The winners score is calculated according to the following rules:

The following table describes the winners points for certain larger values of Han (and sometimes Fu):

han value fu value winner was the dealer? winner's point
13 (any value) True 48000
13 (any value) False 32000
11 or 12 (any value) True 36000
11 or 12 (any value) False 24000
8-10 (any value) True 24000
8-10 (any value) False 16000
6 or 7 (any value) True 18000
6 or 7 (any value) False 12000
5 (any value) True 12000
5 (any value) False 8000
4 40 or more True 12000
4 40 or more False 8000
3 70 or more True 12000
3 70 or more False 8000

If the conditions in the table above do not apply, examine the Fu value.

1. If the Fu value is 25, leave it unchanged. Otherwise, round it up to the nearest multiple of 10 (e.g., 22 and 28 would each be rounded up to 30; 50 would remain 50).

2. Calculate the basic points as Fu 2Han+2.

3. If the winner was also the dealer, he/she wins 6 times the number of basic points, rounded up to the nearest 100 (if it isnt already a multiple of 100).

4. Otherwise (meaning the winner was not the dealer), he/she wins 4 times the number of basic points, rounded up to the nearest 100 (if it isnt already a multiple of 100).

For example, suppose that the dealer won with a score of 2 Han and 32 Fu. We do not have a high enough Han value to use the table above, so we round the Fu value up to 40. The basic points are therefore 40 2(2+2) or 640. Since the winner was also the dealer, we multiply this value by 6 to get 3840, which is rounded up to the nearest hundred, or 3900.

Examples:

function call return value
score(2, 32, True) 3900
score(12, 25, False) 24000
score(4, 20, False) 5200
score(1, 16, False) 700
score(2, 25, True) 2400
score(3, 84, True) 12000

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

Modern Database Management

Authors: Donald A. Carpenter Fred R. McFadden

1st Edition

8178088045, 978-8178088044

More Books

Students also viewed these Databases questions

Question

What behaviors are discouraged?

Answered: 1 week ago

Question

4. Who should be invited to attend?

Answered: 1 week ago

Question

7. How will you encourage her to report back on the findings?

Answered: 1 week ago

Question

Were the decisions based on appropriate facts?

Answered: 1 week ago