Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In many carnival games, such as Soda Toss with Rings, the owner sets up a game and people pay a small fee to play. If

image text in transcribedimage text in transcribedimage text in transcribed

In many carnival games, such as Soda Toss with Rings, the owner sets up a game and people pay a small fee to play. If they "win", they get a "reward" (such as a teddy bear). Your task is to help design a new carnival game by writing a Python program to simulate the new game to ensure that the owner would "make a profit" in a long run In this new carnival game, square grids are drawn on the ground. The distance between lines is d mm. Players would throw the $2 toonie coins into the grid (of very large size). If the toonie touches or crosses any line, they lose the toonie; if it does not touch any line, they would get a "reward" worth $r from the owner (note, the owner still keeps the toonie in this case). See an illustration below For example, if d70 mm (which is about the size of the popular square post-it notes) and r (taking away $2 bet, the player gets $4, or doubles his/her bet), would the owner make money? In this case, three coins touch the lines and two do not. The owner would end up with 5*2 - 2"4- $2, a small gairn You need to write a Python program to simulate the game Your program would take the input as follows (let's assume that input is always valid, and the inputoutput of your program are in bold below) Please enter the distance between lines (in mm) Please enter the "reward" if the customer wins (in $) Then your program would simulate 1,000 toonie tosses, and count how many times the toonies touch or not touch the lines, and then how much the owner would gain or lose at the end of the 1000 toonie tosses. Note the diameter of a standard tonnie is 28 mm If the owner has a profit, your program would output the amount of money gained For the simulation of 1000 toonie tosses, you get $... If the owner loses money, your program would output the amount of money lost: For the simulation of 1000 toonie tosses, you lose $ Note that this problem could be solved analytically with math without simulation, but in this assignment you must run simulation with Python to solve it. This is because many real-world problems are too complex to have analytical solutions. The recent AlphaGo also use a Monte Carlo tree search algorithm (Monte Carlo means simulation) because it is too huge to analyze the whole game trees pythonto solve it This is beausu march igocithm Hint: To simulate the random landing of the toonies, you will need to use a simple loop statement (for) and a random number function called random), which generates a uniformly distributed random number that is 0 and

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

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions