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


Python Team.copy方法代码示例

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


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

示例1: Showdown

# 需要导入模块: from team import Team [as 别名]
# 或者: from team.Team import copy [as 别名]
class Showdown():
    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)

    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)

    def create_initial_gamestate(self):
        self.logger.info("Creating initial gamestate...")
        my_pokes = self.my_team.copy()
        for i, poke in enumerate(my_pokes.poke_list):
            poke_name = poke.name
            if poke_name in NAME_CORRECTIONS:
                poke_name = NAME_CORRECTIONS[poke_name]
            poke.health = poke.final_stats['hp']
            poke.alive = True
        opp_poke_list = []
        log = SimulatorLog.parse(self.selenium.get_log())
        for event in log.events:
            if event.type == "team" and event.details['username'] != self.username:
                opp_poke_names = event.details['team']
        for name in opp_poke_names:
            if not name:
                continue
            poke_name = correct_name(name)
            "Corrected to:", poke_name
            if poke_name in self.smogon_data:
                moveset = [m for m in self.smogon_data[poke_name].movesets if 'Overused' == m['tag'] or 'Underused' == m['tag'] or 'Rarelyused' == m['tag'] or 'Neverused' == m['tag'] or 'Unreleased' == m['tag'] or 'Ubers' == m['tag'] or 'PU' in m['tag']]
                if len(moveset) > 1:
                    moveset = SmogonMoveset.from_dict(moveset[1])
                elif len(moveset) == 1:
                    moveset = SmogonMoveset.from_dict(moveset[0])
                else:
                    moveset = [m for m in self.smogon_bw_data[poke_name].movesets if 'Overused' == m['tag'] or 'Underused' == m['tag'] or 'Rarelyused' == m['tag'] or 'Neverused' == m['tag'] or 'Unreleased' == m['tag'] or 'Ubers' == m['tag'] or 'PU' in m['tag']]
                    moveset = SmogonMoveset.from_dict(moveset[0])
            elif poke_name not in self.smogon_data and poke_name in self.smogon_bw_data:
                moveset = [m for m in self.smogon_bw_data[poke_name].movesets if 'Overused' == m['tag'] or 'Underused' == m['tag'] or 'Rarelyused' == m['tag'] or 'Neverused' == m['tag'] or 'Unreleased' == m['tag'] or 'Ubers' == m['tag'] or 'PU' in m['tag']]
                moveset = SmogonMoveset.from_dict(moveset[0])
            else:
                moveset = SmogonMoveset(None, None, None, {'hp': 88, 'patk': 84, 'pdef': 84, 'spatk': 84, 'spdef': 84, 'spe': 84}, {'hp': 1.0, 'patk': 1.0, 'pdef': 1.0, 'spatk': 1.0, 'spdef': 1.0, 'spe': 1.0}, None, 'ou')
            moveset.moves = None
            if poke_name in self.smogon_data:
                typing = self.smogon_data[poke_name].typing
                stats = self.smogon_data[poke_name].stats
            elif poke_name not in self.smogon_data and poke_name in self.smogon_bw_data:
                typing = self.smogon_bw_data[poke_name].typing
                stats = self.smogon_bw_data[poke_name].stats
            else:
                typing = ['Normal']
                stats = {'hp': 80, 'patk': 80, 'pdef': 80, 'spatk': 80, 'spdef': 80, 'spe': 80}
            predictor = create_predictor(self.predictor_name, name, self.pokedata)
            poke = Pokemon(name, typing, stats, moveset, predictor, calculate=True)
            moves = [x[0] for x in poke.predict_moves([])]
            poke.moveset.moves = moves[:4]
            poke.health = poke.final_stats['hp']
            poke.alive = True
            opp_poke_list.append(poke)
        my_primary = None
        for event in log.events:
            if event.type == "switch" and event.player == 0:
                for poke in my_pokes.poke_list:
                    if poke.name == event.poke:
                        my_primary = my_pokes.poke_list.index(poke)
#.........这里部分代码省略.........
开发者ID:vasumv,项目名称:pokemon_ai,代码行数:103,代码来源:showdown.py


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