Open PeterJCLaw opened 3 years ago
Here's a script which looks for previous times that teams have faced each other:
import collections
def ordinal(n):
# Note: 0-index
if n == 0:
return "first"
if n == 1:
return "second"
if n == 2:
return "third"
if n == 3:
return "fourth"
if n == 4:
return "fifth!?"
raise ValueError("Too big")
def previous_matches(idx, tla):
return [x for match in matches[:idx] if tla in (x := match['main'])]
def nth_match_for_team(idx, tla):
return len(previous_matches(idx, tla))
def opponents_before(idx, tla, teams):
def num_previous_facings(opponent):
return sum(1 for m in previous_matches(idx, opponent) if tla in m)
opponents = set(teams) - set([tla])
return {
opp: count
for opp in opponents
if (count := num_previous_facings(opp)) > 0
}
for idx, match in enumerate(matches):
teams = match['main']
print(f"Match {idx}:")
for tla in teams:
print(f" {tla}: {ordinal(nth_match_for_team(idx, tla))} match | {opponents_before(idx, tla, teams)}")
print()
matches
is a list of {arena: teams}
mappings (i.e: the same format as league.yaml
). Currently assumes a single main
arena.
For pre-match chat the commentators would like to have for each team:
Such as was used on the SR2021 knockouts livestream. The tooling used then is in the compstate:
If that proves to be useful we should pull it into this project.