![]()
A popular dice game is Pig, whose object is to be the first player to score 100 points by rolling two dice and adding their sum to your score. The game is called Pig, because the player can roll as many times as she wants in one turn but, if she gets greedy, she could lose everything because there are risks as well as rewards with each roll of the dice.
The rules to Pig are as follows:
if you roll a one on either dice you lose your points for this
round, and your turn is over.
| if you roll a one on both dice (double ones, or snake eyes) then you lose your points
for the entire game, and your turn is over. | |
So, there are four cases in which one round will end:
The key to winning the game is to know when to stop rolling the dice. You are to try to make a player that is smart enough to regularly increase its score. A player that decides to only roll once, no matter what the result, will probably not reach 100 points very quickly. On the other hand, a player that wants to roll gain all 100 points in one turn will probably lose its points more often than not. So to make your player a winner, choose a strategy that rolls a variable number of times depending on the number of points gained in the game and in the round.
You are to write a program that simulates the game of Pig as well as keeping track of the average number of rounds your strategy takes to win the game. The code has been started in pig.cpp, you should complete it. You must have at least the functions written, although you may add more as you need.
After writing, saving, compiling, and testing your program, answer the following questions (in your README file):
![]()