Created
September 5, 2017 05:42
-
-
Save mpawliuk/5d2444906ff5dab1073de0b3ad7dfe2b to your computer and use it in GitHub Desktop.
Trying to understand a prize distribution from a Reddit comment: https://www.reddit.com/r/mtgjudge/comments/6y1e9u/simple_flat_prize_structure_at_fnm_leads_to_bad/dmkf3io/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Packs = ((points - rounds) - (rounds - 3)) | |
#Take one point off for a perfect record. | |
def points(record): | |
"""Give the number of points a certain record is worth.""" | |
w, l, d = record[:3] | |
return 3 * w + 1 * d | |
def packs_awarded(record, rounds): | |
"""Calculate the number of packs to give someone with a given record.""" | |
total = points(record) - 2 * rounds + 3 | |
return total - 1 if points(record) == 3 * rounds else max(0, total) | |
def nice_show(record): | |
"""Display a record in w-l-d format.""" | |
w, l, d = record[:3] | |
return str(w) + '-' + str(l) + '-' + str(d) | |
def show_pack_distribution(rounds): | |
"""Show how many packs each possible record gets. No ties or drops.""" | |
possible_records = [(i, rounds - i, 0) for i in range(rounds + 1)] | |
for records in possible_records: | |
print '*', nice_show(records), 'gets', packs_awarded(records, rounds), 'packs' | |
return None | |
def compute_records(rounds, records): | |
"""Give how many people of each record there will be, assuming 2^rounds many players. | |
Doesn't work for 5+ rounds because it doesn't take into account pair-up/pair-downs. | |
""" | |
if rounds == 0: | |
return records | |
records.append(0) | |
for i in range(1, len(records)): | |
#print records | |
winners = records[-i-1] | |
#print winners | |
records[-i] += winners / 2 | |
records[-i-1] -= winners / 2 | |
#print rounds-1, records | |
return compute_records(rounds-1, records) | |
def total_packs_given_out(rounds): | |
"""Compute how many total packs are given out.""" | |
records = [(i, rounds - i, 0) for i in range(rounds + 1)] | |
total_packs = 0 | |
for i in range(rounds + 1): | |
total_packs += packs_awarded(records[i], rounds) * compute_records(rounds, [rounds ** 2])[i] | |
print '*', nice_show(records[i]), 'gets', packs_awarded(records[i], rounds), 'packs', compute_records(rounds, [rounds ** 2])[i], 'total people' | |
return total_packs | |
r = 4 | |
#print compute_records(r, [2 ** r]) | |
print total_packs_given_out(r) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment