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