本文整理匯總了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
}