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