Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 ={fiveofkind:False,largestraight: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
image text in transcribed

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

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

More Books

Students also viewed these Databases questions

Question

What are the Five Phases of SDLC? Explain each briefly.

Answered: 1 week ago

Question

How can Change Control Procedures manage Project Creep?

Answered: 1 week ago