The game of Yahtzee is a popular dice game in which players roll 5 dice, and may (optionally) re-roll some or all of the dice on two further rolls. After all three rolls, the best "hand" that can created from the values showing on all of the dice is scored, and the player is awarded points. There are several different types of hands, and a player may only get points for each type of hand once per game.
You are playing Yahtzee, and have taken two of your three rolls. The values showing on the five dice are given in the int[] dice. Based upon the empty slots still available on your score card, and the values showing on the dice, you want to know which dice to re-roll in order to obtain the highest possible expected point outcome. Remember that, statistically speaking, your expected outcome is the probability of an event taking place multiplied by the payoff (in this case, points earned) by that event.
Looking over your scorecard, you realize that the only four remaining items are full house (three of a kind and two of a kind), worth 25 points, small straight (4 consecutive values, no wrapping), worth 30 points, large straight (all five dice are consecutive values), worth 40 points, and Yahtzee (all five dice show the same value), worth 50 points.
You are to return a double indicating the expected score outcome when the player optimally chooses which dice to re-roll.
|