You are coding a simple game called Pig. Players take turns rolling a die. The die determines how many points they get. You may get points each turn your roll (turn points), you also have points for the entire game (grand points). The first player with 100 grand points is the winner. The rules are as follows:
Each turn, the active player faces a decision (roll or hold):
Roll the die. If it's is a:
Hold: Your turn total is added to your grand total. It's now the next players turn.
Make a simple AI with a random number. If you wish you can use this algorithm: For each decision the computer rolls, 1-3 hold, 4-6 roll again. You can also come up with whatever you want to accomplish this task, but beware, there are programming competi- tions to do exactly this with Pig.
// Specification C1 - Fixed Seed
Set the random number seed to a specific integer. That way, it will always generate the same random number sequence - easier to fix bugs that way.
// Specification C2 - Student Name
Allow name to accept first plus last name (ie 2 words). Display it somewhere in the output.
// Specification C3 - Numeric Menu
Use a numeric menu to collect the human players actions. See figure 1 for an example menu.
// Specification C4 - Bulletproof Menu
Detect and re-prompt if incorrect data (i.e. not 1, 2, or 3) is en- tered.
// Specification B1 - Display Turn Stats
Keep track of the points each player scores each turn as well as the overall points both sides have each turn in the game.
//Specification B2 - Display Due Date
Display the date this assignment is due in your program greeting section.
// Specification B3 - Hi Score on Heap
Store the game's high score in a variable in the heap. Dont forget to clean up after yourself before the program quits.
// Specification B4 - Display High Score
Display the value you stored in B3 on the console at the end of the game.
// Specification A1 - D6() function
This method returns a randomly generated int between 1 and 6 every time it's called. Unlike Specification A2, this may or may not occupy its own function. I suggest you use this code somewhere to just confirm it works - but notice between A1 and A2 all your random number needs will be met.
// Specification A2 - RandomNumber() function
Create a function called RandomNumber() which generates a ran- dom number between arguments lo and hi. This function is not a replacement for specification A1. I know you will have two func- tions which do essentially the same thing - but you will only need to use one of them.
// Specification A3 - Protect RandomNumber() input
Using an if statement, protect your RandomNumber() function from bad data. Return a -1 error code if RandomNumber() receives bad input. Argument rules are:
// Specification A4 - Protect RandomNumber() output
Make sure your RandomNumer() function doesn’t send bad output.
Use an if statement before your return to make sure the random
number isn't greater than 100. Return a -2 error code if you gener-
ate bad output.