Question: Enforcing Game Rules ( 1 5 pts ) Game rules require the player to choose one, and only one, score category every round even if

Enforcing Game Rules (15 pts)
Game rules require the player to choose one, and only one, score category every round even if the
category is not achieved. The result is 0 for the selected category. Track which categories have been
selected using a python dictionary. Each key is a category name and the corresponding value is
True/False. For example:
selected ={"five_of_kind":False,"large_straight":False}
scratch_highest_category(selected)- this function is passed a dictionary that
contains True/False for each scoring category. Step through the dictionary from left to
right (highest to lowest score) and change the first category marked False to True. This
prevents the category from being selected a second time (called a scratch). For example, if
five_of_kind has not yet been rolled then it will be first to be scratched since it is the highest
remaining category.
score_dice(dice) update this function. Create a dictionary that holds a pair for the
eight score categories (see above). For each scoring category, only update the game score if the
category is achieved and it has not been selected. Also, mark the category as selected. If no
category is achieved after checking all eight possibiliteis, call
scratch_highest_category(selected).
elif four_of_kind(dice) and not selected.get("four_of_kind"):
score += FOUR_OF_KIND
selected["four_of_kind"]= True
 Enforcing Game Rules (15 pts) Game rules require the player to

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!