Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hold-at-N Turn Strategy A good strategy to help decide when to hold and when to

ID: 660973 • Letter: H

Question

Hold-at-N Turn Strategy A good strategy to help decide when to hold and when to roll is the "hold-at-N strategy": the player chooses a number, N, that will hopefully both maximize their turn score while minimizing their chances of losing that score by rolling a 1; as soon as their current turn score reaches (or passes) N, the player holds. We are going to test this strategy for different values of N, which will be supplied by user input, by simulating a number of turns (which will also be supplied by user input). Obviously, the larger the number of simulations, the better the estimate of probabilities. For instance, suppose the user asks the program to test the strategy for N = 21. We throw the die for a turn ("simulate a turn"), and get the following rolls: Roll 1: 5 - current turn score - 5 Roll 2: 4 - current turn score - 9 Roll 3: 4 - current turn score - 13 Roll 4: 3 - current turn score - 16 Roll 5: 3 - current turn score - 19 Roll 6: 4 - current turn score - 23Now, we end the turn because our score is at least the hold value; we have a turn score of 23 Functions The first function will generate a random integer, given a specified minimum and maximum integer for the range. The second function will execute a single turn of Pig and return the score for that specific turn. R'Sub will test these functions individually, you should implement your functions first and then move on to the core main program that utilizes your functions; testing with R'Sub to make sure your functions are correct prior to moving on. genRandlnt name: genRandlnt return type: integer, the random integer within the range parameters: two integers (order matters) first: the minimum possible random number for the requested range o second: the maximum possible random number for the requested range singleTurn name: singleTurn return type: integer, the score of a single turn parameters: one integer representing the hold value for a single turn

Explanation / Answer

#include #include // Enables use of rand() #include // Enables use of time() #include #include using namespace std; // get random integer number from 1 to 6 int genRandInt () { int randomNum; randomNum = rand () % 6 + 1; return randomNum; } int singleTurn () { srand(333); int currentScore = 0; int currentRoll =0; int holdValue = 0; int turnSimulation = 0; int countZero = 0; // count number of zero int countHoldValue =0; double ProbZero = 0.0; // probabily of zero // probability of holdvalue to holvalue +5 double ProbHoldValue =0.0000000, Prob1 =0.0000000, Prob2=0.0000000; double Prob3 =0.0000000, Prob4 =0.0000000, Prob5 =0.0000000; // variable to count each number in 6 possible outcomes int count1 = 0, count2 = 0; int count3 = 0, count4 = 0, count5 = 0; //get the hold Value from user cout > holdValue; cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote