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 ={"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
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

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

Intelligent Databases Object Oriented Deductive Hypermedia Technologies

Authors: Kamran Parsaye, Mark Chignell, Setrag Khoshafian, Harry Wong

1st Edition

0471503452, 978-0471503453

More Books

Students also viewed these Databases questions