Skip to content

Instantly share code, notes, and snippets.

@PChild
Created July 14, 2018 02:24
Show Gist options
  • Save PChild/cad66fe1cae31b629e1c2d1a12a0f910 to your computer and use it in GitHub Desktop.
Save PChild/cad66fe1cae31b629e1c2d1a12a0f910 to your computer and use it in GitHub Desktop.
SLFF points in python
def calcPoints(team, event):
teamMatches = tba.team_matches(team, event, None, True)
draftPoints = 0
rankPoints = 0
elimPoints = 0
if teamMatches != []:
try:
#Use team status instead of event_district_points since SLFF counts elims and awards points differently...
teamStats = tba.team_status(team, event)
#Find draft points
alliance = teamStats['alliance']
if alliance:
if alliance['pick'] < 2:
draftPoints = 17 - alliance['number']
else:
draftPoints = alliance['number']
#Find quals ranking points
teamCount = teamStats['qual']['num_teams']
teamRank = teamStats['qual']['ranking']['rank']
alpha = 1.07
rankPoints = int(abs(erfinv( (teamCount - 2 * teamRank + 2) / (alpha * teamCount)) * 10 / erfinv( 1 / alpha ) + 12 ) + .5)
except:
pass
#Find points for playing in elims
for match in teamMatches:
if match['comp_level'] != "qm":
if gen.matchResult(team, match) == 'win':
elimPoints += 5
return draftPoints + rankPoints + elimPoints
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment