PeterJCLaw / srcomp-cli

Command line tools for interacting with the state of the Student Robotics Competition
https://github.com/PeterJCLaw/srcomp/wiki
0 stars 2 forks source link

Add tooling to support analysis commentators #20

Open PeterJCLaw opened 3 years ago

PeterJCLaw commented 3 years ago

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.

PeterJCLaw commented 1 year 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.

PeterJCLaw commented 1 year ago

For pre-match chat the commentators would like to have for each team:

PeterJCLaw commented 1 year ago

See also https://github.com/PeterJCLaw/srcomp-screens/issues/1