本文整理汇总了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
示例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)
示例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)
示例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)