Exemple #1
0
        public void MazeNavigator_CalculatesStepsToExit_PartTwo()
        {
            // arrange
            var input = new[] { 0, 3, 0, 1, -3 };

            // act
            var result = MazeNavigator.GetNumberOfStepsToExitPartTwo(input);

            // assert
            Assert.AreEqual(10, result);
        }
        static void Main(string[] args)
        {
            List<string> maze = new List<string>();
            using(StreamReader reader = new StreamReader("../Day5P1Data.txt"))
            {
                while(!reader.EndOfStream)
                {
                    maze.Add(reader.ReadLine());
                }
            }

            MazeNavigator mazeNavigator = new MazeNavigator();
            int stepsForMaze = mazeNavigator.StepsToGetOut(maze);

            Console.WriteLine(stepsForMaze);
        }
Exemple #3
0
        /// <summary>
        ///     Creates the maze navigation world (environment) given the experiment parameters.
        /// </summary>
        /// <param name="walls">The walls in the maze environment.</param>
        /// <param name="navigatorLocation">The starting location of the maze navigator.</param>
        /// <param name="goalLocation">The location of the goal (target).</param>
        /// <param name="minSuccessDistance">The minimum distance from the target for the trial to be considered a success.</param>
        /// <param name="maxDistanceToTarget">The maximum distance from the target possible.</param>
        /// <param name="maxTimeSteps">The maximum number of time steps to run a given trial.</param>
        /// <param name="numBridgingApplications">The number of times to apply bridging during a given trial.</param>
        /// <param name="behaviorCharacterization">The behavior characterization for a navigator.</param>
        private MazeNavigationWorld(List <Wall> walls, DoublePoint navigatorLocation,
                                    DoublePoint goalLocation,
                                    int minSuccessDistance,
                                    int maxDistanceToTarget, int maxTimeSteps,
                                    int numBridgingApplications,
                                    IBehaviorCharacterization behaviorCharacterization = null)
        {
            _walls                    = walls;
            _goalLocation             = goalLocation;
            _minSuccessDistance       = minSuccessDistance;
            _maxDistanceToTarget      = maxDistanceToTarget;
            _maxTimesteps             = maxTimeSteps;
            _behaviorCharacterization = behaviorCharacterization;
            _numBridgingApplications  = numBridgingApplications;

            // Instantiate the navigator
            _navigator = new MazeNavigator(navigatorLocation);
        }
        public void MoveTest()
        {
            List<Wall> walls = new List<Wall>(11)
            {
                // Boundary walls
                new Wall(new DoubleLine(7, 202, 195, 198), -1, -1, 5),
                new Wall(new DoubleLine(41, 5, 3, 8), -1, -1, 5),
                new Wall(new DoubleLine(3, 8, 4, 49), 1, 1, 5),
                new Wall(new DoubleLine(4, 49, 7, 202), 1, 1, 5),
                new Wall(new DoubleLine(195, 198, 186, 8), -1, -1, 5),
                new Wall(new DoubleLine(186, 8, 39, 5), -1, -1, 5),

                // Obstructing walls
                new Wall(new DoubleLine(4, 49, 57, 53), 1, 1, 5),
                new Wall(new DoubleLine(56, 54, 56, 157), -1, 1, 5),
                new Wall(new DoubleLine(57, 106, 158, 162), 1, 1, 5),
                new Wall(new DoubleLine(77, 201, 108, 164), -1, -1, 5),
                new Wall(new DoubleLine(6, 80, 33, 121), -1, 1, 5),
                new Wall(new DoubleLine(192, 146, 87, 91), -1, -1, 5),
                new Wall(new DoubleLine(56, 55, 133, 30), 1, 1, 5)
            };

            //DoublePoint goalLocation = new DoublePoint(270, 100);
            DoublePoint goalLocation = new DoublePoint(31, 20);

            //MazeNavigator navigator = new MazeNavigator(new DoublePoint(30, 22));
            MazeNavigator navigator = new MazeNavigator(new DoublePoint(14.8669777, 190.702774));

            int tempBridgingApplications = 0;

            navigator.Speed = -3;
            navigator.AngularVelocity = -3;
            navigator.Heading = 325.075531;

            navigator.Move(walls, goalLocation, false, ref tempBridgingApplications);

            Console.WriteLine(DoublePoint.CalculateEuclideanDistance(navigator.Location, goalLocation));
        }