def create_robot(maze_env, seed):
    """
    The function to create population of robots.
    """
    params = create_robot_params()
    # Genome has 11 inputs and two outputs
    genome = NEAT.Genome(0, 11, 0, 2, False,
                         NEAT.ActivationFunction.UNSIGNED_SIGMOID,
                         NEAT.ActivationFunction.UNSIGNED_SIGMOID, 0, params,
                         0)
    pop = NEAT.Population(genome, params, True, 1.0, seed)
    pop.RNG.Seed(seed)

    robot_archive = archive.NoveltyArchive(metric=maze.maze_novelty_metric)
    robot = Robot(maze_env=maze_env,
                  archive=robot_archive,
                  genome=genome,
                  population=pop)
    return robot
def create_objective_fun(seed):
    """
    The function to create population of objective functions
    """
    params = create_objective_fun_params()
    # Genome has one input (0.5) and two outputs (a and b)
    genome = NEAT.Genome(
        0,
        1,
        1,
        2,
        False,
        NEAT.ActivationFunction.TANH,  # hidden layer activation
        NEAT.ActivationFunction.UNSIGNED_SIGMOID,  # output layer activation
        1,
        params,
        0)
    pop = NEAT.Population(genome, params, True, 1.0, seed)
    pop.RNG.Seed(seed)

    obj_archive = archive.NoveltyArchive(
        metric=maze.maze_novelty_metric_euclidean)
    obj_fun = ObjectiveFun(archive=obj_archive, genome=genome, population=pop)
    return obj_fun
    local_dir = os.path.dirname(__file__)
    # The directory to store outputs
    out_dir = os.path.join(local_dir, 'out')
    out_dir = os.path.join(out_dir, 'maze_ns_multineat')

    # Clean results of previous run if any or init the ouput directory
    utils.clear_output(out_dir)

    # Run the experiment
    maze_env_config = os.path.join(local_dir, '%s_maze.txt' % args.maze)
    maze_env = maze.read_environment(maze_env_config)
    maze_env.location_sample_rate = args.location_sample_rate

    # Run the maze experiment trials
    print("Starting the %s maze experiment (Novelty Search) with MultiNEAT, for %d trials" % (args.maze, args.trials))
    for t in range(args.trials):
        print("\n\n----- Starting Trial: %d ------" % (t))
        # Create novelty archive
        novelty_archive = archive.NoveltyArchive(threshold=args.ns_threshold,
                                                 metric=maze.maze_novelty_metric)
        trial_out_dir = os.path.join(out_dir, str(t))
        os.makedirs(trial_out_dir, exist_ok=True)
        soulution_found = run_experiment( params=create_params(), 
                                        maze_env=maze_env, 
                                        novelty_archive=novelty_archive,
                                        trial_out_dir=trial_out_dir,
                                        n_generations=args.generations,
                                        args=args,
                                        save_results=True,
                                        silent=True)
    print("\n------ Trial %d complete, solution found: %s ------\n" % (t, soulution_found))