Question: Python Program Skee Ball is an arcade game that lets players roll a ball up an angled surface and into a series of hoops. Players

Python Program

Skee Ball is an arcade game that lets players roll a ball up an angled surface and into a series of hoops. Players earn points based on which hoop their ball falls into. See the image below to see what the game looks like in real life if you havent had the chance to play it yourself.

For this program you will be writing code to simulate the rolling of balls into a virtual Skee Ball playing area. To do this you can repeatedly generate a random coordinate within the Skee Ball area and test to see which hoop (if any) the ball falls into. Note that the playing field is 48" wide by 60" high, so you will be generating random coordinates within this range as part of your simulation.

When you are finished you should calculate the % chance of a ball falling into a particular hoop. Note that, if we all write the code correctly and run it enough times, we should all come up with nearly the same percentages for each possible result -- which will be the actual probabilities of getting each result for a game board with the given dimensions. Using a simulation to discover probabilities in this way is called the Monte Carlo method.

Refer to the schematic below for the exact measurements of the Skee Ball board. Hint: Start off by simulating just one ball toss and compute how many points that toss gets. Once you are confident that you have designed an effective algorithm you can scale up and place your code inside a loop.

Heres a a few sample runnings of the program:

How many throws would you like to simulate? 5000000 Done! Execution time: 20.00 seconds * Total throws: 5,000,000 100.00% * Misses: 3,144,407 62.89% * 10 points: 1,436,146 28.72% * 20 points: 195,887 3.92% * 30 points: 136,021 2.72% * 40 points: 87,539 1.75% How many throws would you like to simulate? -50 Sorry, try again. How many throws would you like to simulate? 100000 Done! Execution time: 0.39 seconds * Total throws: 100,000 100.00% * Misses: 62,856 62.86% * 10 points: 28,689 28.69% * 20 points: 3,943 3.94% * 30 points: 2,717 2.72% * 40 points: 1,795 1.80% 
 

Some hints:

  • You can generate a random floating point number within a given range by using the random.uniform() function. This function takes two arguments - a low boundary and a high boundary - and generates a floating point number within this range (edges inclusive)
  • You can ask Python to generate the current time by calling the time.time() function. You will need to import the time module in order to call this function.
  • You will need to format your output to match the sample output above (i.e. all of your values should line up)
  • Your "execution time" value will likely be different than the ones given here in the sample output. This is due to the fact that every computer will run at a slightly different rate based on processor speed, available memory, etc.

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!