本文整理汇总了Python中hearthbreaker.engine.Game.copy方法的典型用法代码示例。如果您正苦于以下问题:Python Game.copy方法的具体用法?Python Game.copy怎么用?Python Game.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hearthbreaker.engine.Game
的用法示例。
在下文中一共展示了Game.copy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_agent_once
# 需要导入模块: from hearthbreaker.engine import Game [as 别名]
# 或者: from hearthbreaker.engine.Game import copy [as 别名]
def test_agent_once(one, other = None):
#print("game_started")
generator = RandomDeckGenerator()
deck1 = generator.generate()
deck2 = deck1.copy()
if other is None:
other = TradeAgent()
#other = RandomAgent()
game = Game([deck1, deck2], [one, other])
new_game = game.copy()
try:
new_game.start()
# new_data = GameHistoryGenerator.process_history(history, new_game)
# Data = open("data.txt", "a")
# for i in new_data:
# tmp = i[0]
# tmp.append(i[1])
# for j in range(len(tmp)):
# tmp[j] = str(tmp[j])
# Data.write(" ".join(tmp))
# Data.write("\n")
# Data.close()
print("Game lasted: " + str(new_game._turns_passed))
print("winning agent: " + new_game.winner.agent.name)
except Exception as e:
print("Game error: " + str(e))
# raise e
return False
# spark_weights(ql.weights)
return new_game.winner.agent.name
示例2: enshelf_one
# 需要导入模块: from hearthbreaker.engine import Game [as 别名]
# 或者: from hearthbreaker.engine.Game import copy [as 别名]
def enshelf_one(index):
loader = DeckLoader()
generator = RandomDeckGenerator()
# deck1 = loader.load_deck("zoo.hsdeck")
# deck2 = loader.load_deck("zoo.hsdeck")
deck1 = generator.generate()
deck2 = generator.generate()
game = Game([deck1, deck2], [TradeAgent(), TradeAgent()])
new_game = game.copy()
game_log = Hearthlogger()
game_log.attach(new_game)
try:
new_game.start()
except Exception as e:
#print(json.dumps(new_game.__to_json__(), default=lambda o: o.__to_json__(), indent=1))
#print(new_game._all_cards_played)
del new_game
del game_log
print(e)
return False
# print("winning agent: " + new_game.winner.agent.__class__.__name__)
game_log.shelf(index)
del new_game
del game_log
return True
示例3: generate_replays
# 需要导入模块: from hearthbreaker.engine import Game [as 别名]
# 或者: from hearthbreaker.engine.Game import copy [as 别名]
def generate_replays():
loader = DeckLoader()
deck1 = loader.load_deck("patron.hsdeck")
deck2 = loader.load_deck("patron.hsdeck")
game = Game([deck1, deck2], [RandomAgent(), RandomAgent()])
new_game = game.copy()
replay = record(new_game)
try:
new_game.start()
except Exception as e:
print(json.dumps(new_game.__to_json__(), default=lambda o: o.__to_json__(), indent=1))
print(new_game._all_cards_played)
raise e
replay.write_json("replay_text.hsreplay")
del new_game
print("done!")
示例4: test_agent_once
# 需要导入模块: from hearthbreaker.engine import Game [as 别名]
# 或者: from hearthbreaker.engine.Game import copy [as 别名]
def test_agent_once(one, other):
generator = RandomDeckGenerator()
deck1 = generator.generate()
deck2 = deck1.copy()
if other is None:
other = TradeAgent()
#other = RandomAgent()
game = Game([deck1, deck2], [one, other])
new_game = game.copy()
try:
new_game.start()
except Exception as e:
print("Game error: " + str(e))
raise e
# raise
#print(json.dumps(new_game.__to_json__(), default=lambda o: o.__to_json__(), indent=1))
# new_game
return False
print("Game lasted: " + str(new_game._turns_passed))
print("winning agent: " + new_game.winner.agent.name)
# spark_weights(ql.weights)
return new_game.winner.agent.name