Question
THIS IS A C++ CODE. You are coding a simple game called Pig. The rules are as follows: Two players (you and the computer) are
THIS IS A C++ CODE.
You are coding a simple game called Pig. The rules are as follows:
Two players (you and the computer) are racing to reach 100 points. Each turn, the active player faces a decision:
Hold: take your turn total and add it to the player's overall total. The next player becomes active.
Roll: generate a random number between 1 and 6. Results are: * 1 Lose turn, no turn total added to overall total. All the
points you have accumulated this turn are lost. * 2..6 Add this number to the turn total. Player goes again.
Constraints.
Use Structured Programming or Object Oriented Programming Techniques.
Use function prototypes and comment them. Every program you write in this class has this constraint EVEN IF NOT EXPRESSLY STATED.
Compiler warnings are NOT acceptable. Compiler warnings result from the compiler finding a potential problem in your source file. They are not tolerated in a production environment. Your code must compile clean. Every program you write in this class has this constraint EVEN IF NOT EXPRESSLY STATED.
Make a simple AI by randomly generating a number 1,2,3 - hold, 4,5,6 - roll, etc.
Start your source file with a file header. This includes program name, 1 sentence description, your name, class number and the date. Every program you write in this class has this constraint EVEN IF NOT EXPRESSLY STATED.
Display a program greeting as soon as the program runs. This introduces the program and tells your clients what it does. Try to keep this short - 1, 2 sentences. Every program you write in this class has this constraint EVEN IF NOT EXPRESSLY STATED.
Use white space and comments to make your code more readable. Every program you write in this class has this constraint EVEN IF NOT EXPRESSLY STATED.
Keep count of the number of turns it took to win/lose.
Create a more sophisticated AI (ex: look at the difference between
the player and computer scores and adjust the random numbers to make the AI take more or less risk.). Note: there is a competition on building AIs for this - keep your new AI simple.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started