當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。