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


Python GameState.get_team方法代码示例

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


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

示例1: main

# 需要导入模块: from gamestate import GameState [as 别名]
# 或者: from gamestate.GameState import get_team [as 别名]
def main():
    from argparse import ArgumentParser

    argparser = ArgumentParser()
    argparser.add_argument('team1')
    argparser.add_argument('team2')
    argparser.add_argument('--depth', type=int, default=2)
    argparser.add_argument('--gamestate', type=str)
    argparser.add_argument('--player', type=int, default=0)
    args = argparser.parse_args()
    pokedata = load_data("data")

    players = [None, None]
    # players[args.player] = HumanAgent()
    players[args.player] = PessimisticMinimaxAgent(2, pokedata, log_file="normal.txt")
    # players[1 - args.player] = PessimisticMinimaxAgent(2, pokedata, log_file="no_cache.txt", use_cache=False)
    # players[1 - args.player] = DumbAgent()
    players[1 - args.player] = HumanAgent()

    with open(args.team1) as f1, open(args.team2) as f2, open("data/poke2.json") as f3:
        data = json.loads(f3.read())
        poke_dict = Smogon.convert_to_dict(data)
        teams = [Team.make_team(f1.read(), poke_dict), Team.make_team(f2.read(), poke_dict)]

    gamestate = GameState(teams)
    if args.gamestate is not None:
        with open(args.gamestate, 'rb') as fp:
            gamestate = pickle.load(fp)
    with open('cur2.gs', 'wb') as fp:
        pickle.dump(gamestate, fp)
    gamestate.create_gamestate_arff(0)
    gamestate.print_readable_data(0)
    gamestate.print_readable_data(1)
    simulator = Simulator(pokedata)
    while not gamestate.is_over():
        print "=========================================================================================="
        print "Player 1 primary:", gamestate.get_team(0).primary(), gamestate.get_team(0).primary().status
        print "Player 2 primary:", gamestate.get_team(1).primary(), gamestate.get_team(1).primary().status
        print ""

        my_action = players[0].get_action(gamestate, 0)
        opp_action = players[1].get_action(gamestate, 1)
        gamestate = simulator.simulate(gamestate, [my_action, opp_action], 0, log=True)
    if gamestate.get_team(0).alive():
        print "You win!"
        print "Congrats to", gamestate.opp_team
        print "Sucks for", gamestate.my_team
    else:
        print "You lose!"
        print "Congrats to", gamestate.my_team
        print "Sucks for", gamestate.opp_team
    gamestate.turn += 1
开发者ID:jy19,项目名称:CS478-Pokemon,代码行数:54,代码来源:game.py


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