public void MarkSolutionPath_PathToSolutionHasSomeElements_MazeHasSameNumberOfGridpointsOnSolutionPath() { var listOfMazeGridpoints = new List <MazeGridpoint> { new MazeGridpoint(new CartesianCoordinate(2, 0), new DirectionsAvailable(), true, false, false), new MazeGridpoint(new CartesianCoordinate(0, 2), new DirectionsAvailable(), false, false, true), new MazeGridpoint(new CartesianCoordinate(1, 1), new DirectionsAvailable(), false, false, false), new MazeGridpoint(new CartesianCoordinate(2, 1), new DirectionsAvailable(), false, false, false), new MazeGridpoint(new CartesianCoordinate(3, 1), new DirectionsAvailable(), false, false, false), new MazeGridpoint(new CartesianCoordinate(1, 2), new DirectionsAvailable(), false, false, false), new MazeGridpoint(new CartesianCoordinate(2, 2), new DirectionsAvailable(), false, false, false), new MazeGridpoint(new CartesianCoordinate(3, 2), new DirectionsAvailable(), false, false, false), new MazeGridpoint(new CartesianCoordinate(1, 3), new DirectionsAvailable(), false, false, false), new MazeGridpoint(new CartesianCoordinate(2, 3), new DirectionsAvailable(), false, false, false), new MazeGridpoint(new CartesianCoordinate(3, 3), new DirectionsAvailable(), false, false, false), new MazeGridpoint(new CartesianCoordinate(4, 2), new DirectionsAvailable(), false, false, false), new MazeGridpoint(new CartesianCoordinate(2, 4), new DirectionsAvailable(), false, true, false) }; var maze = new Maze(listOfMazeGridpoints.ToDictionary(m => m.Position, m => m)); var solutionPath = new List <MazeSolutionElement> { new MazeSolutionElement { MazeGridpoint = maze.MazeGridpoints[new CartesianCoordinate(2, 0)] }, new MazeSolutionElement { MazeGridpoint = maze.MazeGridpoints[new CartesianCoordinate(2, 1)] }, new MazeSolutionElement { MazeGridpoint = maze.MazeGridpoints[new CartesianCoordinate(2, 2)] }, new MazeSolutionElement { MazeGridpoint = maze.MazeGridpoints[new CartesianCoordinate(2, 3)] }, new MazeSolutionElement { MazeGridpoint = maze.MazeGridpoints[new CartesianCoordinate(2, 4)] } }; var mazeSolution = new MazeSolution(maze); mazeSolution.PathToSolveMaze = solutionPath; mazeSolution.MarkSolutionPath(); Assert.AreEqual( mazeSolution.PathToSolveMaze.Count(), mazeSolution.MazeToSolve.MazeGridpoints.Values.Count(m => m.IsOnSolutionPath)); }
// This test was used for tracking the progress of some solver algorithms running in release mode public void ConvertTextOutputToSolutionPathOnMazeImage() { const string mazeImageFilePath = @"..\..\..\SampleMazes\Maze2.png"; const string mazeSolutionTextFilePath = @"..\..\..\SampleMazesSolutions\SampleMaze2\WallHugging.txt"; const string mazeImageSolutionFilePath = @"..\..\..\SampleMazesSolutions\SampleMaze2\Maze2SolutionProgress.png"; var mazeReader = new MazeReaderUtility(mazeImageFilePath); var maze = mazeReader.ReadInMazeImage(); var fileLines = File.ReadAllLines(mazeSolutionTextFilePath); var count = fileLines.Count(); var mazeSolutionPath = new List <MazeSolutionElement>(); for (var i = 0; i < count; i++) { var line = fileLines[i]; var splitLine = line.Split(' ', ','); var xPosition = Convert.ToInt32(splitLine[2]); var yPosition = Convert.ToInt32(splitLine[6]); var coordinate = new CartesianCoordinate(xPosition, yPosition); var mazeGridpoint = maze.MazeGridpoints[coordinate]; var solutionElement = new MazeSolutionElement { MazeGridpoint = mazeGridpoint, }; mazeSolutionPath.Add(solutionElement); fileLines[i] = null; } var mazeSolution = new MazeSolution(maze) { PathToSolveMaze = mazeSolutionPath }; var mazeWriter = new MazeWriterUtility(mazeImageSolutionFilePath, mazeSolution.MazeToSolve); mazeSolution.MarkSolutionPath(); mazeWriter.SaveMazeImage(); }