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


Python Game.copy方法代码示例

本文整理汇总了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
开发者ID:jirenz,项目名称:CS229_Project,代码行数:34,代码来源:agent_test.py

示例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
开发者ID:jirenz,项目名称:CS229_Project,代码行数:27,代码来源:boardstate_test.py

示例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!")
开发者ID:jirenz,项目名称:CS229_Project,代码行数:19,代码来源:Replay_generator.py

示例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
开发者ID:jirenz,项目名称:CS229_Project,代码行数:25,代码来源:production.py


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