Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using python3 to solve the problem The Japac version of Mahjong is a four-player game with somewhat complicated scoring rs. Each player begins with a

image text in transcribedimage text in transcribed

Using python3 to solve the problem

The Japac version of Mahjong is a four-player game with somewhat complicated scoring rs. 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 throe arguments . An integer in the rane 1-13 representing the Han value .An integer representing the Ph value, which is either 25 or an even number in the range 20-130 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 don't care how many points each of the other players wll 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 winner's score is calculated according to the following rules: The following table describes the winner's points for certain larger values of Han (and sometimes Fu) an value inner was t innor's Points False any value False value False any valuFalse or or or or value) True or more or more or moreTrue or more rue . If the conditions in the table above do not apply, examine the Pu value. 1. If the A value i 25, eit unchangod. Otherwise, round it up to the net multiple of 10 (e.g., 22 and 28 would each be rounded up to 30; 50 would remain 50) 2. Caleulate the basic points as Fu x 2an2 3. If the winner wias also the dealer, he/she wins 6 times the number of basie points, rounded up to the nenrest 100 (if it isn't already a multiple of 100) 4 Otherwise meaning the winner was not the dealer , he she wins 4 times the number of blHc points, rounded up to the nearst 100 (if it isn't alrendy a multiple of 100) For example, supposthat the dealer won with a score of 2 Han and 32 . We do not have a high enough Han value to use the nble above, so we round the MI value up to 40 l'he blwic 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: inction score(2, 32, True) score (12. 25, score(4. 20. False) score (1, 16. False score(2, 25, True score(3, 84. True) oturn Valuo 3900 24000 5200 700 2400 12000 The Japac version of Mahjong is a four-player game with somewhat complicated scoring rs. 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 throe arguments . An integer in the rane 1-13 representing the Han value .An integer representing the Ph value, which is either 25 or an even number in the range 20-130 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 don't care how many points each of the other players wll 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 winner's score is calculated according to the following rules: The following table describes the winner's points for certain larger values of Han (and sometimes Fu) an value inner was t innor's Points False any value False value False any valuFalse or or or or value) True or more or more or moreTrue or more rue . If the conditions in the table above do not apply, examine the Pu value. 1. If the A value i 25, eit unchangod. Otherwise, round it up to the net multiple of 10 (e.g., 22 and 28 would each be rounded up to 30; 50 would remain 50) 2. Caleulate the basic points as Fu x 2an2 3. If the winner wias also the dealer, he/she wins 6 times the number of basie points, rounded up to the nenrest 100 (if it isn't already a multiple of 100) 4 Otherwise meaning the winner was not the dealer , he she wins 4 times the number of blHc points, rounded up to the nearst 100 (if it isn't alrendy a multiple of 100) For example, supposthat the dealer won with a score of 2 Han and 32 . We do not have a high enough Han value to use the nble above, so we round the MI value up to 40 l'he blwic 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: inction score(2, 32, True) score (12. 25, score(4. 20. False) score (1, 16. False score(2, 25, True score(3, 84. True) oturn Valuo 3900 24000 5200 700 2400 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_2

Step: 3

blur-text-image_3

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

Object Oriented Databases Prentice Hall International Series In Computer Science

Authors: John G. Hughes

1st Edition

0136298745, 978-0136298748

More Books

Students also viewed these Databases questions