Create a subdirectory of your home directory named Skunk not

Create a subdirectory of your home directory named Skunk (note the case). Save your solutions in that directory, in files named skunk1.c, skunk2.c and skunk3.c. Your programs are due Wednesday October 26 at 4:00PM. You will not receive any credit if your programs are late, have the wrong filenames, or are in the wrong directory. Write a C program that plays one round of Skunk. Allow the user of the program to choose when to quit. Write a C program that plays multiple rounds of Skunk. Instead of having the user choose when to stop rolling the dice, write a strategy function that has the current score as a parameter and which decides when to stop rolling. Play a number of rounds (specified by a #define) and print the average score. Your strategy function should be based on the current score, i.e., roll again if the score is less than some specified amount, and stop if the score is greater than or equal to that amount. Write a C program that finds the best Skunk strategy.

Solution

You can include the function below in the code written in part 1 to achieve the result of part 2.

#define round 5
int Roll_Dice(int rounds)
{
int cur_score = 10; // We have assumed that the current score is 10.
int sum = 0, average = 0;
int arr[round],arr2[round]; // We will use array for storing the score after each roll.
int r ,i ,j;
l: for(i=0,j=0;i<5,j<5;i++,j++) // Using both the variables in the loop.
{
r = rand() % 6 + 1; // We are generating the random numbers because dice has 1-6 values.
arr[i] = r;
   r = rand() % 6 + 1;
   arr2[j] = r;
   if(arr[i]!=1 || arr2[j]!=1)
   {
   if(arr[i] == arr[j]) // Check if there is double
   sum = 0; // Points are wiped out
}
   else {
average = sum/round; // Added otherwise
}
if(sum >= cur_score) // Check if sum greater than current score
printf(\"%d\",average); // Print out the average
else
goto l; // Else execute the loop again

return 0;
}

3. The game of Skunk is totally based on the probabilistic events, hence there is no such strategy
if the number of the rounds are defined.
If in case the number are not defined then one can go for the value which has more sum as outcome of
both the dice.




 Create a subdirectory of your home directory named Skunk (note the case). Save your solutions in that directory, in files named skunk1.c, skunk2.c and skunk3.c

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site