from typing import List
import re


def get_runtime_data(name: str):
    """
    Retrieves the runtime results from a file.
    :param name:        The filename
    :return:            Dictionary with the data separated by number of teams
    """
    with open(f'../../{name}.txt') as f:
        data = dict()
        for line in f.readlines():
            matches: List[re.Match] = re.findall(
                '^\w+-\d+x\d+-A(\d+)_T(\d+), \w+-\d+x\d+-A\d+_T\d+-(\d+).map, ([\d.]+|None)$', line)
            agents = int(matches[0][0])
            teams = int(matches[0][1])
            time = float('nan' if matches[0][3] == 'None' else matches[0][3])
            if teams in data.keys():
                if agents in data[teams].keys():
                    data[teams][agents].append(time)
                else:
                    data[teams][agents] = [time]
            else:
                data[teams] = dict()
                data[teams][agents] = [time]
    return data