Question: In python pls The Japanese version of Mahjong is a four-player game with somewhat complicated scoring rules. Each player begins with a specified number of

In python pls

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?

Winners Points

13

(any value)

True

48,000

13

(any value)

False

32,000

11 or 12

(any value)

True

36,000

11 or 12

(any value)

False

24,000

810

(any value)

True

24,000

810

(any value)

False

16,000

6 or 7

(any value)

True

18,000

6 or 7

(any value)

False

12,000

5

(any value)

True

12,000

5

(any value)

False

8,000

4

40 or more

True

12,000

4

40 or more

False

8,000

3

70 or more

True

12,000

3

70 or more

False

8,000

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

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).

Calculate the basic points as Fu 2Han+2.

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).

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

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!