Question: You will implement a program that hands out gear to the players of a particular game. You may theme your game as you wish. Your

You will implement a program that hands out gear to the players of a particular game. You may

theme your game as you wish.

Your program will use probabilities to decide what gear to hand out to the player. The gear includes

a dagger, a helment, a shield, and armor.

Your Program

All of the gear that will be handed out is represented by a token in a bag. To begin, there are 2

daggar tokens, 3 helmet tokens, 3 shield tokens, and 4 armor tokens in the Token Bag.

The program will choose a token from the bag and give that gear to the player. To simulate which

token was chosen, you will compute the probability of choosing each piece of gear and hand out

the gear with the highest probability of being chosen. If there is a tie, the user gets both (or all)

of the gear with the same probability.

You should display the probabilities of each kind of gear in a table before handing out the gear.

See the sample output for how to format the probabilities.

Remember, you cannot directly compare doubles. You have to compare using

abs(x-y) < EPSILON

where EPSILON is some very small number, like 1e-14.

Here is an example for what your programs output could look like. Yours doesnt have to look

exactly like this, as long as it prints out the right things. User input is in blue.

--------------------------------

Title Goes Here

--------------------------------

Purpose Goes Here

--------------------------------

P(Armor) = 4/12

P(Dagger) = 2/12

P(Helmet) = 3/12

P(Shield) = 3/12

Youve earned Armor

Try again for more gear? y/n y

P(Armor| A) = 3/11

P(Dagger| A) = 2/11

P(Helmet| A) = 3/11

P(Shield| A) = 3/11

You could earn a

1. Armor

2. Helmet

3. Shield

Which one do you want to keep? 3

Try again for more gear? y/n y

P(Armor| A AND S) = 3/10

P(Dagger| A AND S) = 2/10

P(Helmet| A AND S) = 3/10

P(Shield| A AND S) = 2/10

You could earn a

1. Armor

2. Helmet

Which one do you want to keep? 2

Try again for more gear? y/n y

P(Armor| A AND S AND H) = 3/9

P(Dagger| A AND S AND H) = 2/9

P(Helmet| A AND S AND H) = 2/9

P(Shield| A AND S AND H) = 2/9

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!