A strategy is
A single function that makes
Ten thousand choices.
This contest is completely optional!
Download a blank
hog_contest.py file and simple tests for correct formatting
as a zip archive. Type
python3 ok to run the provided tests.
hog_contest.py file containing a function called
python3 ok --submit
The contest ends on Sunday, July 1st at 11:59 PM. We will use your latest submission before this date to determine the final results of the contest.
To make things more interesting, we've introduced a new rule (Time Trot) in addition to the original set of special rules. Here is the entire set of rules:
Pig Out. If any of the dice outcomes is a 1, the current player's score for the turn is 1.
- Example 1: The current player rolls 7 dice, 5 of which are 1's. They score 1 point for the turn.
- Example 2: The current player rolls 4 dice, all of which are 3's. Since Pig Out did not occur, they score 12 points for the turn.
Free Bacon. A player who chooses to roll zero dice scores the one more than the last digit of the product of the digits in the opponent's score.
- Example 1: The opponent has 46 points, and the current player chooses to roll zero dice. 4 * 6 = 24; the last digit is a 4, so the current player gains 4 + 1 = 5 points.
- Example 2: The opponent has 28 points, and the current player chooses to roll zero dice. 2 * 8 = 16; the last digit is a 6, so the current player gains 6 + 1 = 7 points.
- Example 3: The opponent has 5 points, and the current player chooses to roll zero dice. 0 * 5 = 0; the last digit is a 0, so the current player gains 0 + 1 = 1 point.
Swine Swap. After points for the turn are added to the current player's score, if the ones digit of the current player's score is the same as the tens digit of the opponent's score, the two scores are swapped.
- Example 1: The current player has a total score of 41 and the opponent has 92. The current player rolls two dice that total 8. The player's new score is 49, and the opponent's score is 92. The ones and tens digits are the same (49 and 92), so the scores are swapped! The current player now has 92 points and the opponent has 49. The turn ends.
- Example 2: The current player has a total score of 34 and the opponent has 5. The current player rolls three dice that total 6. The player's new score is 40, and the ones digit is the same as the opponent's tens digit (40 and 05), so the scores are swapped. The current player now has 5 points and the opponent has 40.
- Example 3: The current player has a total score of 91 and the opponent has 12. The current player rolls five dice that total 20. The player's new score is 111, and the ones digit is the same as the opponent's tens digit (111 and 12), so the scores are swapped. The opponent ends the turn with 111 points and wins the game.
Time Trot. A turn involves a player rolling dice, and each turn is numbered, starting from 0. If a player chooses to roll a number of dice
n % 8 == k, then that player gets an extra turn immediately after the current turn. However, a player cannot get an extra turn immediately after an extra turn.
- On Turn 0, Player 0 rolls 6 dice that total 20. The score is 20 to 0.
- On Turn 1, Player 1 rolls 1 die that comes up 4. The score is now 20 to 4. Player 1 gets an extra turn because 1 % 8 = 1.
- On Turn 2, Player 1 rolls 2 dice that total 7. The score is 20 to 11. Even though 2 % 8 = 2, Player 1 does not get an extra turn because Player 1 cannot get two extra turns in a row.
- On Turn 3, Player 0 rolls 3 dice and pigs out, causing a Swine Swap. The score is now 11 to 21, and Player 0 gets an extra turn because 3 % 8 = 3.
- On Turn 4, Player 0 rolls (...)
- Note: A strategy must be a deterministic function of the players' scores and cannot track the turn number or previous actions. See complete contest rules below.
This is a solo contest. Each submitted strategy will play against all other submissions. We will exactly compute the expected win rate for each player, so that the outcome of this tournament will be determined by strategy alone and not the roll of the dice. A submission scores a match point each time it has an expected win rate above 50.0001%. We will rank submissions based on the number of matches they won. Ties count as losses.
The top three submissions will earn the following:
- First place gets 3 points of extra credit.
- Second place gets 2 points of extra credit.
- Third place gets 1 point of extra credit.
Winners will also be publicly recognized in future iterations of 61A!
Some additional contest rules:
- Calling your
final_strategyfunction on every possible pair of scores should take less than 10 seconds. The provided tests check for this.
- All strategies must be deterministic, pure functions of the current player scores! Non-deterministic strategies or strategies based on the history of the game will be disqualified.
We expect everyone to play fair. Attempts to "game the system" will not be tolerated.
If you have any questions about the rules, don't hesitate to post on Piazza.