/* PigletSolitaireHoldAt2Player - a simple Piglet Solitaire player that holds at a turn total of 2 of if the turn total is sufficient for a win.
 * 
 * Piglet Solitaire is a simple jeopardy coin game.  The goal is to reach a given goal score in a given number of turns.
 * Initially, a player's score is 0, the turn total is zero, and the turn number is 0.  (The last possible turn number is the number of turns - 1.)
 * A player's choice is always simply whether to "flip" a coin or to "hold" and end the turn.
 * If the player chooses to "flip" there are two equiprobable outcomes:
 *   HEAD - the turn total increases by 1, and the turn continues, or
 *   TAIL - the turn total resets to 0, and the turn ends with the score unchanged. Note that the turn number increments at the end of a turn.
 * If the player chooses to "hold", the score is increased by the turn total, the turn total resets to 0, and turn ends.
 * The player wins if, within a given number of turns, the player's score reaches a given goal score.
 * An optimal player chooses to "flip" or "hold" so as to maximize the probability of winning.
 * 
 * @author Todd W. Neller
 */
public class PigletSolitaireHoldAt2Player implements PigletSolitairePlayer {

	double goalScore;

	@Override
	public void initialize(int goalScore, int numTurns) {
		this.goalScore = goalScore;
	}

	@Override
	public boolean willFlip(int score, int turnTotal, int turn) {
		return turnTotal < 2 && score + turnTotal < goalScore; // hold with a turn total of 2 or if turn total is enough to reach the goal score
	}

}
