當前位置: 首頁>>代碼示例>>Python>>正文


Python Team.make_team方法代碼示例

本文整理匯總了Python中team.Team.make_team方法的典型用法代碼示例。如果您正苦於以下問題:Python Team.make_team方法的具體用法?Python Team.make_team怎麽用?Python Team.make_team使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在team.Team的用法示例。


在下文中一共展示了Team.make_team方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: from team import Team [as 別名]
# 或者: from team.Team import make_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

示例2: __init__

# 需要導入模塊: from team import Team [as 別名]
# 或者: from team.Team import make_team [as 別名]
 def __init__(self, team_text, agent, username, pokedata, password=None,
              monitor_url=None, proxy=False, browser='phantomjs', predictor_name='PokeFrequencyPredictor',
              verbose=False, kernel_dir="kernel", kernel=False, lib_dir="lib"):
     self.logger = logging.getLogger("showdown")
     self.logger.setLevel(level=logging.INFO)
     self.agent = agent
     self.username = username
     self.password = password
     self.team_text = team_text
     self.predictor_name = predictor_name
     self.monitor_url = monitor_url
     self.battle_url = None
     self.pokedata = pokedata
     self.smogon_data = pokedata.smogon_data
     self.smogon_bw_data = pokedata.smogon_bw_data
     self.graph_move = pokedata.graph_move
     self.graph_poke = pokedata.graph_poke
     self.poke_moves = pokedata.poke_moves
     self.my_team = Team.make_team(team_text, self.smogon_data)
     self.opp_team = None
     self.simulator = Simulator(pokedata)
     arch = platform.architecture()
     self.lib_dir = Path(lib_dir) / OS_MAP[arch[0]][arch[1]]
     self.selenium = Selenium(proxy=proxy, browser=browser, lib_dir=self.lib_dir)
     self.verbose = verbose
     self.kernel_dir = Path(kernel_dir)
     self.kernel = kernel
     if self.kernel and not self.kernel_dir.exists():
         self.kernel_dir.mkdir()
     self.state = KernelState(self.kernel_dir / KERNEL_STATE, self.kernel)
     self.state.update_state("status", "idle")
     if self.verbose:
         self.logger.setLevel(level=logging.DEBUG)
開發者ID:vasumv,項目名稱:pokemon_ai,代碼行數:35,代碼來源:showdown.py

示例3: reset

# 需要導入模塊: from team import Team [as 別名]
# 或者: from team.Team import make_team [as 別名]
 def reset(self):
     self.state.update_state("status", "idle")
     self.logger.info("Resetting...")
     self.simulator.score = 0
     self.simulator.total = 0
     self.selenium.reset()
     self.opp_team = None
     self.my_team = Team.make_team(self.team_text, self.smogon_data)
開發者ID:vasumv,項目名稱:pokemon_ai,代碼行數:10,代碼來源:showdown.py

示例4: ArgumentParser

# 需要導入模塊: from team import Team [as 別名]
# 或者: from team.Team import make_team [as 別名]
    from argparse import ArgumentParser

    argparser = ArgumentParser()
    argparser.add_argument('team1')
    argparser.add_argument('team2')

    args = argparser.parse_args()

    import json
    from smogon import Smogon
    from team import Team
    from gamestate import GameState

    with open('log.txt', 'r') as fp:
        log_text = fp.read()

    log = SimulatorLog.parse(log_text)

    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)

    from simulator import Simulator

    simulator = Simulator()
    for event in log.events:
        simulator.handle_event(gamestate, event)
開發者ID:jy19,項目名稱:CS478-Pokemon,代碼行數:32,代碼來源:log.py


注:本文中的team.Team.make_team方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。