public void CannotSolveTests() { string maze1 = "__________\r\n" + "________XX\r\n" + "S_______XG"; string maze2 = "S________XG"; WalkingSolver solver = new WalkingSolver(); Assert.IsFalse(solver.SolveMaze(new Maze.Maze(maze1), new ASCIIFormatter())); Assert.IsFalse(solver.SolveMaze(new Maze.Maze(maze2), new ASCIIFormatter())); }
/// <summary> /// Main program entry point. Run from the command line /// and supply the full or relative path to a maze file. /// </summary> /// <param name="args"></param> static void Main(string[] args) { if (args.GetLength(0) != 1) { Console.WriteLine("Usage: Maze <Maze file>"); return; } try { using (StreamReader sr = new StreamReader(args[0])) { WalkingSolver solver = new WalkingSolver(); if (solver.SolveMaze(new Maze(sr.ReadToEnd()), new ASCIIFormatter())) { Console.WriteLine(solver.GetMazeSteps()); int x = Console.CursorLeft; int y = Console.CursorTop; foreach (string s in solver.GetGraphicalMazeSteps()) { Console.SetCursorPosition(x, y); Console.WriteLine(s); System.Threading.Thread.Sleep(250); } } else { Console.WriteLine("Maze cannot be solved."); } } } catch (FileNotFoundException) { Console.WriteLine("Invalid maze file specified"); } }
public void SampleSolveTest() { string m = "_____GX_" + "\r\n" + "____XXX_" + "\r\n" + "________" + "\r\n" + "XXXX____" + "\r\n" + "___X____" + "\r\n" + "S_______"; WalkingSolver solver = new WalkingSolver(); Assert.IsTrue(solver.SolveMaze(new Maze.Maze(m), new ASCIIFormatter())); }