Pig!

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:

  1. The object is to accumulate 100 points before your opponent.
  2. Points are the sum of the numbers showing on the two dice.
  3. On your turn, you may roll as many times as you like, but
    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:

  1. Losing your points for the round by rolling a one on one of the dice.
    For example, suppose the player has gained 67 points so far in the game. PigRound is called with the value 67. Now, suppose the player rolls and gets a one and a five. The turn should end and return a score of 67.
     
  2. Losing all your points by rolling a one on both of the dice.
    Suppose again the player has gained 67 points. PigRound is called with a value of 67 and a one is rolled on both dice. The turn should end and return a score of 0.
     
  3. Winning by gaining 100 points.
    Suppose PigRound is called with 90 points and the player rolls a six and a five; the turn should end and return 101.
     
  4. Choosing not to be a pig
    The player has rolled and gained some points and voluntarily stops the turn instead of risking another roll. Again, suppose PigRound is called with a value of 67. The player rolls a 13, then a 7, and then decides that is enough. The function should return 87.

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):

  1. State in English your strategy for playing a single round.
  2. How many points do you think is won in a "good" round?
  3. What is the maximum number of points you scored in a single round?
  4. What is the minimum number of rounds it took you to reach 100 points?