当前位置: 首页>>代码示例>>Python>>正文


Python Team.start_new_game方法代码示例

本文整理汇总了Python中team.Team.start_new_game方法的典型用法代码示例。如果您正苦于以下问题:Python Team.start_new_game方法的具体用法?Python Team.start_new_game怎么用?Python Team.start_new_game使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在team.Team的用法示例。


在下文中一共展示了Team.start_new_game方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run_simulated_games

# 需要导入模块: from team import Team [as 别名]
# 或者: from team.Team import start_new_game [as 别名]
def run_simulated_games(away_team_name, home_team_name, game_count=10):
    """Run a number of simulated games between two teams."""
    print "Running simulations between %s and %s" %\
        (away_team_name, home_team_name)
    if conf.pitcher_sub_model is None:
        conf.pitcher_sub_model = joblib.load(
            './models/%s' % conf.used_pitcher_model_name)
    away_team = Team(away_team_name)
    home_team = Team(home_team_name)
    agg_batters = []
    agg_scores = []
    agg_pitchers = []
    game_no = 0
    while game_no < game_count:
        print "Running game %d of %d. (%s vs. %s)" %\
            (game_no + 1, game_count, away_team_name, home_team_name)
        away_team.start_new_game()
        home_team.start_new_game()
        game_log, score, pit_stats, bat_stats = play_game(away_team, home_team)
        agg_scores.append(score)
        agg_pitchers.append(pit_stats)
        agg_batters.append(bat_stats)
        game_no += 1

    """Convert data to final display format."""
    batters_fanduel = {}
    batters_draftkings = {}
    pitchers_fanduel = {}
    pitchers_draftkings = {}
    wins = {
        away_team_name: 0,
        home_team_name: 0
    }
    runs = {
        away_team_name: [],
        home_team_name: []
    }
    for idx, entry in enumerate(agg_scores):
        runs[away_team_name].append(entry[0])
        runs[home_team_name].append(entry[1])
        if entry[0] > entry[1]:
            wins[away_team_name] += 1
        else:
            wins[home_team_name] += 1
        for name in agg_batters[idx].index:
            if name in batters_draftkings:
                batters_draftkings[name].append(
                    agg_batters[idx].at[name, 'DKP'])
                batters_fanduel[name].append(agg_batters[idx].at[name, 'FDP'])
            else:
                batters_draftkings[name] = [agg_batters[idx].at[name, 'DKP']]
                batters_fanduel[name] = [agg_batters[idx].at[name, 'FDP']]
        for name in agg_pitchers[idx].index:
            if name in batters_draftkings:
                del batters_draftkings[name]
                del batters_fanduel[name]
            if name in pitchers_draftkings:
                pitchers_draftkings[name].append(
                    agg_pitchers[idx].at[name, 'DKP'])
                pitchers_fanduel[name].append(
                    agg_pitchers[idx].at[name, 'FDP'])
            else:
                pitchers_draftkings[name] = [agg_pitchers[idx].at[name, 'DKP']]
                pitchers_fanduel[name] = [agg_pitchers[idx].at[name, 'FDP']]
    return {
        'wins': wins,
        'runs': runs,
        'batters_fd': batters_fanduel,
        'batters_dk': batters_draftkings,
        'pitchers_fd': pitchers_fanduel,
        'pitchers_dk': pitchers_draftkings
    }
开发者ID:nataliemeurer,项目名称:fantasysports,代码行数:74,代码来源:simulation_runner.py


注:本文中的team.Team.start_new_game方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。