Esempio n. 1
0
def find_todays_games(teams):
    games_list = []
    today = datetime.today()
    today_string = '%s-%s-%s' % (today.month, today.day, today.year)

    for game in Boxscores(today).games[today_string]:
        # Skip the games that are not between two DI teams since stats are not
        # saved for those teams.
        if game['non_di']:
            continue
        games_list.append(populate_game_info(teams, game))
    return games_list
Esempio n. 2
0
def power_ranking_matchups(matchups, teams, rankings):
    matches = []

    for match in matchups:
        home, away = match
        game = {
            'away_abbr': away,
            'away_name': teams(away).name,
            'away_rank': rankings.get(away, None),
            'home_abbr': home,
            'home_name': teams(home).name,
            'home_rank': rankings.get(home, None),
            'top_25': rankings.get(away, None) or rankings.get(home, None)
        }
        matches.append(populate_game_info(teams, game))
    return matches
Esempio n. 3
0
def create_matches(matchups, teams, rankings):
    matches = []

    for matchup in matchups:
        home_abbr, away_abbr = matchup
        home = teams(home_abbr)
        away = teams(away_abbr)
        game = {
            'home_name': home.name,
            'home_abbr': home_abbr,
            'home_rank': rankings.get(home_abbr, None),
            'away_name': away.name,
            'away_abbr': away_abbr,
            'away_rank': rankings.get(away_abbr, None),
            'top_25': rankings.get(home_abbr, None) or \
                      rankings.get(away_abbr, None)
        }
        matches.append(populate_game_info(teams, game))
    return matches
Esempio n. 4
0
def get_remaining_schedule(conference_teams, teams, rankings):
    # remaining_schedule is a list of lists with the inner list being
    # the home first, followed by the away team (ie. [home, away])
    remaining_schedule = []
    current_records = {}

    for abbreviation, team in conference_teams.items():
        current_records[abbreviation] = team.conference_wins
        for game in team.schedule:
            # Find all conference matchups that the team hasn't played yet.
            if game.opponent_abbr in conference_teams and \
               not game.points_for and \
               game.type == REGULAR_SEASON:
                top_25 = rankings.get(team.abbreviation.lower(), None) or \
                         rankings.get(game.opponent_abbr.lower(), None)
                if game.location == AWAY:
                    game = {
                        'home_name': game.opponent_name,
                        'home_abbr': game.opponent_abbr.lower(),
                        'home_rank': game.opponent_rank,
                        'away_name': team.name,
                        'away_abbr': team.abbreviation.lower(),
                        'away_rank': rankings.get(team.abbreviation.lower(),
                                                  None),
                        'top_25': top_25
                    }
                else:
                    game = {
                        'home_name': team.name,
                        'home_abbr': team.abbreviation.lower(),
                        'home_rank': rankings.get(team.abbreviation.lower(),
                                                  None),
                        'away_name': game.opponent_name,
                        'away_abbr': game.opponent_abbr.lower(),
                        'away_rank': game.opponent_rank,
                        'top_25': top_25
                    }
                remaining_schedule.append(populate_game_info(teams, game))
    # Return a list of non-duplicate matches
    schedule = list(s for s, _ in itertools.groupby(remaining_schedule))
    return schedule, current_records
Esempio n. 5
0
def start_matchup_simulation(predictor, teams, rankings, num_sims, home, away):
    matches = []

    game = {
        'away_abbr': away,
        'away_name': teams(away).name,
        'away_rank': rankings.get(away, None),
        'home_abbr': home,
        'home_name': teams(home).name,
        'home_rank': rankings.get(home, None),
        'top_25': rankings.get(away, None) or rankings.get(home, None)
    }
    game = populate_game_info(teams, game)
    matches = [game] * num_sims
    stats_dict, stdev_dict = find_stdev_for_every_stat(teams, rankings)
    match_stats, games = aggregate_match_stats(stats_dict, stdev_dict, matches,
                                               num_sims)
    predictions = create_predictions(match_stats, predictor)
    total_points, num_wins = determine_outcomes(predictions, games)
    prediction_list = determine_overall_results([game], total_points, num_wins,
                                                num_sims)
    display_predictions(prediction_list)