Optional Contest: Hog Strategy

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.

Submit a hog_contest.py file containing a function called final_strategy and a PLAYER_NAME.

python3 ok --submit

The contest ends on Thursday, July 9th 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 can run for as long as you want. If ok complains that you're exceeding the time limit, run it with the flag --timeout 0 to disable the time limit.


The leaderboard can be found here. It will continuously update as the contest progresses. Go to the server log to see the status of your submission.

Contest rules

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. To avoid issues relating to floating-point inaccuracy, 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:

  1. First place gets 3 points of extra credit.
  2. Second place gets 2 points of extra credit.
  3. Third place gets 1 point of extra credit.

Winners will also be publicly recognized in future iterations of 61A!

Some additional contest rules:

  • 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 any libraries (such as NumPy, TensorFlow, or anything else you can think of) in your submission.
  • Please don't do anything nefarious to learn about or influence other students' submissions.

If you have any questions about the rules, don't hesitate to post on Piazza.

Happy coding!