
/**
 * Driver class that performs repeated PigGame simulations.
 *   @author Dave Reed
 *   @version 9/13/17
 */
public class PigStats {
    private final static int NUM_GAMES = 1000000;

    /**
     * Simulates repeated games of 1-player Pig.
     *   @param cutoff the point total at which the player holds (cutoff > 0)
     *   @return the average number of rounds required to win
     */
    public double averageLengthOfGame(int cutoff) {
        PigGame game = new PigGame(cutoff);
        
        int totalRounds = 0;
        for (int i = 0; i < PigStats.NUM_GAMES; i++) {
            totalRounds += game.playGame();
        }
        return (double)totalRounds/PigStats.NUM_GAMES;
    }

    public void showGameStats(int lowCutoff, int highCutoff)
    {
        for (int i = lowCutoff; i <= highCutoff; i++) {
            PigGame game = new PigGame(i);
            System.out.println(i + ": " + game.averageLengthOfGame(PigStats.NUM_GAMES));
        }
    }
}
