Exemplo n.º 1
0
        /// <summary>
        ///     Maze Navigator fitness initialization evaluator constructor.
        /// </summary>
        /// <param name="minSuccessDistance">The minimum distance from the target to be considered a successful run.</param>
        /// <param name="maxDistanceToTarget">The maximum distance from the target possible.</param>
        /// <param name="startingEvaluations">The number of evaluations from which the evaluator is starting (defaults to 0).</param>
        public MazeNavigatorFitnessInitializationEvaluator(int minSuccessDistance,
                                                           int maxDistanceToTarget, ulong startingEvaluations = 0)
        {
            EvaluationCount = startingEvaluations;

            // Create factory for generating mazes
            _multiMazeWorldFactory = new MultiMazeNavigationWorldFactory <FitnessInfo>(minSuccessDistance,
                                                                                       maxDistanceToTarget);
        }
        /// <summary>
        ///     Maze Navigator MCS evaluator constructor.
        /// </summary>
        /// <param name="minSuccessDistance">The minimum distance from the target to be considered a successful run.</param>
        /// <param name="behaviorCharacterizationFactory">The initialized behavior characterization factory.</param>
        /// <param name="agentNumSuccessesCriteria">
        ///     The number of mazes that must be solved successfully in order to satisfy the
        ///     minimal criterion.
        /// </param>
        public MazeNavigatorMCCEvaluator(int minSuccessDistance,
                                         IBehaviorCharacterizationFactory behaviorCharacterizationFactory, int agentNumSuccessesCriteria)
        {
            _behaviorCharacterizationFactory = behaviorCharacterizationFactory;
            _agentNumSuccessesCriteria       = agentNumSuccessesCriteria;
            EvaluationCount = 0;

            // Create factory for generating multiple mazes
            _multiMazeWorldFactory = new MultiMazeNavigationWorldFactory <BehaviorInfo>(minSuccessDistance);
        }
        /// <summary>
        ///     Maze Environment MCS evaluator constructor.
        /// </summary>
        /// <param name="minSuccessDistance">The minimum distance from the target to be considered a successful run.</param>
        /// <param name="behaviorCharacterizationFactory">The initialized behavior characterization factory.</param>
        /// <param name="numAgentsSolvedCriteria">
        ///     The number of successful attempts at maze navigation in order to satisfy the
        ///     minimal criterion.
        /// </param>
        /// <param name="numAgentsFailedCriteria">
        ///     The number of failed attempts at maze navigation in order to satisfy the minimal
        ///     criterion.
        /// </param>
        public MazeEnvironmentMCCEvaluator(int minSuccessDistance,
                                           IBehaviorCharacterizationFactory behaviorCharacterizationFactory, int numAgentsSolvedCriteria,
                                           int numAgentsFailedCriteria)
        {
            _behaviorCharacterizationFactory = behaviorCharacterizationFactory;
            _numAgentsSolvedCriteria         = numAgentsSolvedCriteria;
            _numAgentsFailedCriteria         = numAgentsFailedCriteria;

            // Create factory for maze world generation
            _multiMazeWorldFactory = new MultiMazeNavigationWorldFactory <BehaviorInfo>(minSuccessDistance);
        }
        /// <summary>
        ///     Maze Navigator fitness initialization evaluator constructor.
        /// </summary>
        /// <param name="minSuccessDistance">The minimum distance from the target to be considered a successful run.</param>
        /// <param name="maxDistanceToTarget">The maximum distance from the target possible.</param>
        /// <param name="behaviorCharacterizationFactory">The initialized behavior characterization factory.</param>
        /// <param name="startingEvaluations">The number of evaluations from which the evaluator is starting (defaults to 0).</param>
        public MazeNavigatorNoveltySearchInitializationEvaluator(int minSuccessDistance,
                                                                 int maxDistanceToTarget, IBehaviorCharacterizationFactory behaviorCharacterizationFactory,
                                                                 ulong startingEvaluations = 0)
        {
            EvaluationCount = startingEvaluations;
            _behaviorCharacterizationFactory = behaviorCharacterizationFactory;

            // Create factory for generating mazes
            _multiMazeWorldFactory = new MultiMazeNavigationWorldFactory <BehaviorInfo>(minSuccessDistance,
                                                                                        maxDistanceToTarget);
        }
        public void SetMazeConfigurationsTest()
        {
            // Setup constant parameters
            const int maxTimesteps = 300;
            const int minSuccessDistance = 5;

            // Create some dummy structures/walls
            IList<MazeStructure> mazeStructures = new List<MazeStructure>
            {
                new MazeStructure(300, 300, 1)
                {
                    Walls = {new MazeStructureWall(5, 5, 10, 10), new MazeStructureWall(6, 6, 11, 11)}
                },
                new MazeStructure(300, 300, 1)
                {
                    Walls = {new MazeStructureWall(7, 7, 12, 12), new MazeStructureWall(8, 8, 13, 13)}
                },
                new MazeStructure(300, 300, 1)
                {
                    Walls = {new MazeStructureWall(9, 9, 14, 14), new MazeStructureWall(10, 10, 15, 15)}
                },
                new MazeStructure(300, 300, 1)
                {
                    Walls = {new MazeStructureWall(11, 11, 16, 16), new MazeStructureWall(12, 12, 17, 17)}
                },
                new MazeStructure(300, 300, 1)
                {
                    Walls = {new MazeStructureWall(13, 13, 18, 18), new MazeStructureWall(14, 14, 19, 19)}
                }
            };

            // Create the factory
            MultiMazeNavigationWorldFactory<BehaviorInfo> factory =
                new MultiMazeNavigationWorldFactory<BehaviorInfo>(maxTimesteps, minSuccessDistance);

            // Attempt setting the configurations
            factory.SetMazeConfigurations(mazeStructures);

            // Ensure number of mazes is 2
            Debug.Assert(factory.NumMazes == 5);

            // Remove one of the dummy structures
            mazeStructures.RemoveAt(0);

            // Call again with one of the mazes removed
            factory.SetMazeConfigurations(mazeStructures);

            // Ensure that no longer extant maze was removed
            Debug.Assert(factory.NumMazes == 4);
        }