A strategy is
A single function that makes
Ten thousand choices.
This contest is completely optional!
Download a blank
final_strategy.py file and simple tests for correct
formatting as a zip archive. Type
python3 ok to run the provided tests.
final_strategy.py file containing a function called
python3 ok --submit
If you see an SSL error when trying to submit, that's an issue with your local installation of Python 3 on Mac OS X. Navigate to
Applications/Python 3.[Version]and run
Install Certificates.commandby double-clicking it.
The contest ends on Monday, September 20 at 11:59 PM. We will use your latest submission before this date to determine the final results of the contest.
You can use the
compare_strategies.py file to compute the exact win rate
between any pair of two strategies using our server. Depending on server load,
we may rate-limit or disable this functionality at any point, so consider
re-implementing this file yourself locally!
Your strategy should not take more than about 5 minutes to run on a single-threaded machine with about 8GB of RAM. Specifically, the following loop should take no more than about 5 minutes:
for i in range(300): for j in range(300): final_strategy(i, j)
We won't enforce this strictly, but strategies that take significantly longer to run (hours, days) or require special hardware (e.g. GPUs) to run fast will be disqualified.
Teams can have one or two people. Each person can only be part of one team.
Each submitted strategy will play against all other submissions. The player to go first will be determined by a flip of a fair coin. 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 or flip of a coin. A submission scores a match point each time it has an expected win rate strictly 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.
To make things more interesting, we've introduced a new rule (Time Trot) in addition to the original set of special rules. Here are the full set of rules:
- Sow Sad. If any of the dice outcomes is a 1, the current player's score
for the turn is
- Example 1: The current player rolls 7 dice, 5 of which are 1's. They
1point for the turn.
- Example 2: The current player rolls 4 dice, all of which are 3's. Since
Sow Sad did not occur, they score
12points for the turn.
- Picky Piggy. A player who chooses to roll zero dice scores the
nth digit of the decimal expansion of 1/7 (0.14285714...), where
nis the opponent's score. As a special case, if
nis 0, the player scores 7 points.
- Example 1: The current player rolls zero dice and the opponent has a score of 3.
The 3rd digit of the decimal expansion of 1/7 is 2:
0.1485714285714285, The current player will receive
- Example 2: The current player rolls zero dice and the opponent has a score of 14.
The 14th digit of the decimal expansion of 1/7 is 4:
0.1428571428571285, so the current player will receive
- Example 3: The current player rolls zero dice and the opponent has a score of 0.
The current player will receive
- Hog Pile. After points for the turn are added to the current player's score, if the players' scores are the same, the current player's score doubles.
- Both players start out at 0. (0, 0)
- Player 0 rolls 2 dice and gets
5points. (5, 0)
- Player 1 rolls 1 dice and gets
5points. Player 1's score doubles. (5, 10)
- Player 0 rolls 2 dice and gets
6points. (11, 10)
- Player 1 rolls 8 dice and gets
1points. Player 1's score doubles. (11, 22)
- 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 another extra turn.
To discourage you from just hard-coding your program output in your submission, we have introduced a size penalty for large submissions. Specifically, your
GOAL_SCORE will not simply be
100, but will instead depend on the size of the
final_strategy.py file that you submit, according to the following function:
def target_score(program_size_in_bytes): scaled_score = program_size_in_bytes / 10000 * 300 return int(min(max(scaled_score, 50), 300))
Your program size and target score will be printed when you submit, and will also be displayed on the scoreboard.
- 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 not behave as expected when submitted and will likely not do well.
- You may use most general-purpose libraries (such as the standard library, NumPy, or a C compiler) in your submission. Make sure all your logic is in the
final_strategy.pyfile that you submit. If you are unsure whether you can use a particular library, ask us!
- You may import functions from the files provided in the
hog_contestfolder, but may not modify them. If you want to use any other logic from your
hog.pyproject file, you must copy it into
If you have any questions about the rules, don't hesitate to post on Piazza.