本文整理匯總了Python中gtp.Engine方法的典型用法代碼示例。如果您正苦於以下問題:Python gtp.Engine方法的具體用法?Python gtp.Engine怎麽用?Python gtp.Engine使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gtp
的用法示例。
在下文中一共展示了gtp.Engine方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: make_gtp_instance
# 需要導入模塊: import gtp [as 別名]
# 或者: from gtp import Engine [as 別名]
def make_gtp_instance(read_file, readouts_per_move=2000, verbosity=1, cgos_mode=False):
n = DualNetwork(read_file)
instance = MCTSPlayer(n, simulations_per_move=readouts_per_move,
verbosity=verbosity, two_player_mode=True)
gtp_engine = gtp.Engine(instance)
if cgos_mode:
instance = CGOSPlayer(n, seconds_per_move=5,
verbosity=verbosity, two_player_mode=True)
else:
instance = MCTSPlayer(n, simulations_per_move=readouts_per_move,
verbosity=verbosity, two_player_mode=True)
name = "Somebot-" + os.path.basename(read_file)
gtp_engine = gtp_extensions.GTPDeluxe(instance, name=name)
return gtp_engine
示例2: make_gtp_instance
# 需要導入模塊: import gtp [as 別名]
# 或者: from gtp import Engine [as 別名]
def make_gtp_instance(strategy_name, read_file):
n = PolicyNetwork(use_cpu=True)
n.initialize_variables(read_file)
if strategy_name == 'random':
instance = RandomPlayer()
elif strategy_name == 'policy':
instance = GreedyPolicyPlayer(n)
elif strategy_name == 'randompolicy':
instance = RandomPolicyPlayer(n)
elif strategy_name == 'mcts':
instance = MCTSPlayer(n)
else:
return None
gtp_engine = gtp.Engine(instance)
return gtp_engine
示例3: make_gtp_instance
# 需要導入模塊: import gtp [as 別名]
# 或者: from gtp import Engine [as 別名]
def make_gtp_instance(board_size, read_file, readouts_per_move=100,
verbosity=1, cgos_mode=False):
n = DualNetRunner(read_file)
instance = MCTSPlayer(board_size, n, simulations_per_move=readouts_per_move,
verbosity=verbosity, two_player_mode=True)
gtp_engine = gtp.Engine(instance)
if cgos_mode:
instance = CGOSPlayer(board_size, n, seconds_per_move=5,
verbosity=verbosity, two_player_mode=True)
else:
instance = MCTSPlayer(board_size, n, simulations_per_move=readouts_per_move,
verbosity=verbosity, two_player_mode=True)
name = 'Somebot-' + os.path.basename(read_file)
gtp_engine = gtp_extensions.GTPDeluxe(instance, name=name)
return gtp_engine
示例4: setUp
# 需要導入模塊: import gtp [as 別名]
# 或者: from gtp import Engine [as 別名]
def setUp(self):
self.engine = Engine(MinimalGame())
示例5: setUp
# 需要導入模塊: import gtp [as 別名]
# 或者: from gtp import Engine [as 別名]
def setUp(self):
model = DummyModel()
self.gtp_engine = Engine(model, 'test.log')
示例6: gtp
# 需要導入模塊: import gtp [as 別名]
# 或者: from gtp import Engine [as 別名]
def gtp(strategy, read_file=None):
n = PolicyNetwork(use_cpu=True)
if strategy == 'random':
instance = RandomPlayer()
elif strategy == 'policy':
instance = PolicyNetworkBestMovePlayer(n, read_file)
elif strategy == 'randompolicy':
instance = PolicyNetworkRandomMovePlayer(n, read_file)
elif strategy == 'mcts':
instance = MCTS(n, read_file)
else:
sys.stderr.write("Unknown strategy")
sys.exit()
gtp_engine = gtp_lib.Engine(instance)
sys.stderr.write("GTP engine ready\n")
sys.stderr.flush()
while not gtp_engine.disconnect:
inpt = input()
# handle either single lines at a time
# or multiple commands separated by '\n'
try:
cmd_list = inpt.split("\n")
except:
cmd_list = [inpt]
for cmd in cmd_list:
engine_reply = gtp_engine.send(cmd)
sys.stdout.write(engine_reply)
sys.stdout.flush()