Exemplo n.º 1
0
        public void PreTreatMazeToSolve_SuperSimpleMaze_RedundantWhiteSpaceIsRemovedThenDeadEndsAreFound()
        {
            const string mazeImageFilePath = @"..\..\..\TestingMazes\SuperSimpleMaze.png";
            var          mazeReader        = new MazeReaderUtility(mazeImageFilePath);
            var          mazeToPreTreat    = mazeReader.ReadInMazeImage();

            var preTreatmentOne = new RemoveAllEasilyIdentifiableDeadEnds(mazeToPreTreat);

            preTreatmentOne.PreTreatMazeToSolve();

            Assert.AreEqual(mazeToPreTreat.MazeGridpoints.Values.Count(m => m.HasBeenVisited), 0);

            var preTreatmentTwo = new RemoveRedundantWhiteSpace(mazeToPreTreat);

            preTreatmentTwo.PreTreatMazeToSolve();

            var gridpointsRemovedAsRedundant = mazeToPreTreat.MazeGridpoints.Values.Count(m => m.HasBeenVisited);

            Assert.AreEqual(gridpointsRemovedAsRedundant, 710);

            var preTreatmentThree = new DetermineAllOpenPaths(mazeToPreTreat);

            preTreatmentThree.PreTreatMazeToSolve();

            var preTreatmentFour = new RemoveAllEasilyIdentifiableDeadEnds(mazeToPreTreat);

            preTreatmentFour.PreTreatMazeToSolve();

            Assert.IsTrue(mazeToPreTreat.MazeGridpoints.Values.Count(m => m.HasBeenVisited) > gridpointsRemovedAsRedundant);
        }
        public void PreTreatMazeToSolve_UltraTinyMaze_CellsHaveFourOpenPaths()
        {
            const string mazeImageFilePath = @"..\..\..\TestingMazes\UltraTinyMaze.png";
            var          mazeReader        = new MazeReaderUtility(mazeImageFilePath);
            var          mazeToPreTreat    = mazeReader.ReadInMazeImage();

            Assert.IsTrue(mazeToPreTreat.MazeGridpoints
                          .All(g => g.Value.DirectionsAvailable.Count == 4));

            var preTreatment = new DetermineAllOpenPaths(mazeToPreTreat);

            preTreatment.PreTreatMazeToSolve();

            Assert.IsTrue(mazeToPreTreat.MazeGridpoints
                          .All(g => g.Value.DirectionsAvailable.Count != 4));
        }
Exemplo n.º 3
0
        public void PreTreatMazeToSolve_UltraTinyMaze_TwentyNineDeadEndPointsAreMarked()
        {
            const string mazeImageFilePath = @"..\..\..\TestingMazes\UltraTinyMaze.png";
            var          mazeReader        = new MazeReaderUtility(mazeImageFilePath);
            var          mazeToPreTreat    = mazeReader.ReadInMazeImage();

            var preTreatmentOne = new DetermineAllOpenPaths(mazeToPreTreat);

            preTreatmentOne.PreTreatMazeToSolve();

            var preTreatmentTwo = new RemoveAllEasilyIdentifiableDeadEnds(mazeToPreTreat);

            preTreatmentTwo.PreTreatMazeToSolve();

            var deadEndsMarked = mazeToPreTreat.MazeGridpoints.Values.Count(m => m.HasBeenVisited);

            Assert.AreEqual(deadEndsMarked, 29);
        }