Question: In C++ original code below. Problem C: OAB Simulator In this problem, start with the one-armed bandit (OAB) spinning wheel game from the HW2C problem.

In C++ original code below.

In C++ original code below. Problem C: OAB Simulator In this problem,start with the one-armed bandit (OAB) spinning wheel game from the HW2Cproblem. You need to re-write your code such that you can run

Problem C: OAB Simulator In this problem, start with the one-armed bandit (OAB) spinning wheel game from the HW2C problem. You need to re-write your code such that you can run the one-armed bandit *many* more times. The goal is to simulate the probability of winning for several different combinations of the number of wheels and the range of values on each wheel. Let w be the number of wheels to be simulated (w=4 in HW2C). "d" will remain the range of values on a wheel (1 to d). Write a function spin_the_wheels(d, w) that takes integer values d and was input parameters. Your function should return an integer 1 if all w values match from the simulated spin of the wheels. Otherwise, it should return 0. An example declaration: int spin_the_wheels(int d, int w); Now put this function within a for loop that calls the function n times and counts the number of times that the function returns 1. Call this count of the number of wins, m. Then the ratio m is a simulated estimate of the probability of winning with the given values of d and w. The larger the value of n, the better the estimate will be. The next step is to enclose this loop within another loop that varies the value of d, and then enclose both of those loops into another loop that varies the value of w. This process will produce estimates of winning for a range of values of d and w. Write a program that performs the above simulation experiment for w = 3, 4, 5, 6 and d = 9, 12, 15, ..., 27. Use n = 1,000,000 for each experiment. Your program should print the values of w and d followed by the simulated win probability and the theoretical win probability. Your program will also have to compute the theoretical win probability. You will need to divide the total number of ways to win by the total number of possible combinations. A win is defined to be the case when all w wheels have the same value. Since there are d unique values on each wheel, there are d ways in which you can win (1,1,1,1 or 2,2,2,2, etc.). The total number of combinations possible with w wheels is du = (d * d * ... * d) = pow(d,w). So, the theoretical probability of winning is d / pow(d,w). Your program will also have to compute the theoretical win probability. You will need to divide the total number of ways to win by the total number of possible combinations. A win is defined to be the case when all w wheels have the same value. Since there are d unique values on each wheel, there are d ways in which you can win (1,1,1,1 or 2,2,2,2, etc.). The total number of combinations possible with w wheels is dw = (d * d * ... * d) = pow(d,w). So, the theoretical probability of winning is d/pow(d,w). Example Output #1: w=3, d=9: Simulated probability = m = 1.23231. Theoretical Probability = 1.234578. w=3, d=12: Simulated probability = m = 0.70639. Theoretical Probability = 0.6944448. w=3, d=15: Simulated probability = m = 0.44438. Theoretical Probability = 0.4444448. Example Output #2: w=3, d=9: Simulated probability = m = 1.22098. Theoretical Probability - 1.234578. w=3, d=12: Simulated probability = m = 0.68939. Theoretical Probability = 0.6944448. w=3, d=15: Simulated probability = m = 0.4527%. Theoretical Probability = 0.4444448. The values above should be replaced with the values computed by your program (the variables used to compute the percentages should be of type double; the counts should all be of type int). Your answers may be slightly different from those above! This is a random process. Note that if we run the program several times it probably will NOT give the exact same numbers for the simulated probabilities. If it does return the same values when run several times, then check that you have seeded your random number generation correctly. Test Cases This program takes no variable inputs. As such there is just one test case. == #include #include using namespace std; int main() 9{ srand(time(NULL)); int ni, n2, n3, n4, d; while (true) { cout > d; if (d -1) break; nl = 1 + (rand() % d); n2 = 1 + (rand() $d); n3 = 1 + (rand() $d); n4 = 1 + (rand() % d); cout

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!