CSC 421: Algorithm Design and Analysis
Spring 2018

HW1: Brute Force Goat


Consider a children's game named Goat, which has some similarities to the popular dice game Pig. Goat is a two-player game in which the players take turns rolling dice and accumulating points. During each turn in Goat, a player can choose to put up to six six-sided dice into a cup and roll them simultaneously (by dumping the cup onto a table). If any of the rolled dice have the same value, then the player's turn is over and they receive no points for that turn. If all of the dice faces are different, however, then the player earns points equal to the sum of all the dice faces and they can choose whether to roll again. A player can roll as many as three times on the same turn, earning the sum of all the dice rolls (if no matches occurred) or 0 points (if a match occurred). For example, suppose a player chooses to roll three dice, and rolls 3, 4, and 1. If they choose to stop, then they would earn 3+4+1=8 points for the round and it would then be the other player's turn. Suppose they chose to continue, and rolled 5, 2, and 4, giving them a running total of 19 points. Suppose they again chose to continue and rolled 2, 6, and 2. Since there were matching 2s, the player's turn is over and they earn no points for the turn.

The game begins with each player having 0 points, and they take turns rolling until someone reaches 100 points and is declared the winner. If both players reach 100 in the same turn, whichever has the most points is declared the winner (or it is a tie if they both have the same number of points).

For this assignment, you are to create a program for determining the best strategy for playing Goat. For the sake of simplicity, we will assume that you must play the entire game with the same strategy, i.e., you can't change your strategy based on the current score. Given that constraint, there are really two different parameters that determine the strategy. One is the number of dice to roll; the other is the threshold, i.e., the number of points that you would need to have earned to voluntarily end your turn. For example, you might decide to roll four dice and stop when the number of points earned on a turn reaches 20.

Note: to test the effectiveness of a particular strategy, e.g., 4 dice up to 20, you don't need to simulate a game between two players. What you really need to simulate is how many turns it takes, on average, for a player to reach 100 points. Presumably, the fewer turns it takes, the better a player's chances of winning.

In addition to your simulation program, you must submit your recommendation for the best Goat strategy, along with a justification and the data you generated to support your answer.