def _init_bot(bot_type, game, player_id): """Initializes a bot by type.""" rng = np.random.RandomState(FLAGS.seed) if bot_type == "mcts": evaluator = mcts.RandomRolloutEvaluator(FLAGS.rollout_count, rng) return mcts.MCTSBot( game, FLAGS.uct_c, FLAGS.max_simulations, evaluator, random_state=rng, solve=FLAGS.solve, verbose=FLAGS.verbose) if bot_type == "az": model = az_model.Model.from_checkpoint(FLAGS.az_path) evaluator = az_evaluator.AlphaZeroEvaluator(game, model) return mcts.MCTSBot( game, FLAGS.uct_c, FLAGS.max_simulations, evaluator, random_state=rng, child_selection_fn=mcts.SearchNode.puct_value, solve=FLAGS.solve, verbose=FLAGS.verbose) if bot_type == "random": return uniform_random.UniformRandomBot(player_id, rng) if bot_type == "human": return human.HumanBot() if bot_type == "gtp": bot = gtp.GTPBot(game, FLAGS.gtp_path) for cmd in FLAGS.gtp_cmd: bot.gtp_cmd(cmd) return bot raise ValueError("Invalid bot type: %s" % bot_type)
def _init_bot(bot_type, game, player_id): """Initializes a bot by type.""" rng = np.random.RandomState(FLAGS.seed) if bot_type == "mcts": evaluator = mcts.RandomRolloutEvaluator(FLAGS.rollout_count, rng) return mcts.MCTSBot(game, FLAGS.uct_c, FLAGS.max_simulations, evaluator, random_state=rng, solve=FLAGS.solve, verbose=FLAGS.verbose) if bot_type == "random": return uniform_random.UniformRandomBot(player_id, rng) if bot_type == "human": return human.HumanBot() if bot_type == "gtp": return gtp.GTPBot(game, FLAGS.gtp_path) raise ValueError("Invalid bot type: %s" % bot_type)