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


Python GameState.remove_runner方法代码示例

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


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

示例1: play_game

# 需要导入模块: from game_state import GameState [as 别名]
# 或者: from game_state.GameState import remove_runner [as 别名]
def play_game(away_team, home_team, starting_inn=1):
    """Run a single simulation between two teams."""
    gs = GameState(away_team, home_team, starting_inn)
    # play the game
    while gs.game_on():
        # play innings
        # test for stolen bases, pitcher replacement, etc
        stolen_base = steal_base(gs) # returns index of runner that's attempting
        if stolen_base >= 0:
            ran = r.rand()
            # if it's a success, give it to them.  If not, they're out.
            if ran < gs.bases[stolen_base].get_stolen_base_chance()['success']:
                gs.add_stolen_base(stolen_base)
            else:
                gs.remove_runner(stolen_base)
            continue
        # test if pitcher replaced
        if gs.get_stage() == 'top':
            if home_team.get_pitcher() == home_team.get_starting_pitcher():
                if replace_pitcher(gs, home_team.get_pitcher()):
                    home_team.replace_pitcher('Relief')
                    continue
        elif gs.get_stage() == 'bot':
            if away_team.get_pitcher() == away_team.get_starting_pitcher():
                if replace_pitcher(gs, away_team.get_pitcher()):
                    away_team.replace_pitcher('Relief')
        # compute batter outcomes
        if gs.get_stage() == 'top':
            batter = away_team.get_player(gs.batting_pos[0])
            pitcher = home_team.get_pitcher()
            outcome = play_batter(gs, batter, pitcher, home_team.get_name())
        else:
            batter = home_team.get_player(gs.batting_pos[1])
            pitcher = away_team.get_pitcher()
            outcome = play_batter(gs, batter, pitcher, home_team.get_name())
        gs.update_game(outcome, batter, pitcher)
    return gs.get_game_stats()
开发者ID:nataliemeurer,项目名称:fantasysports,代码行数:39,代码来源:simulation_runner.py


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