예제 #1
0
        public void AutoExplore_when_called_for_minimalistic_maze_returns_route()
        {
            var explorer = new Explorer(MinimalMaze);

            var route = AutoExplorer.Explore(explorer).ToArray();

            Assert.AreEqual(new Cell(0, 1), route[0]);
            Assert.AreEqual(new Cell(1, 1), route[1]);
            Assert.AreEqual(new Cell(2, 1), route[2]);
        }
예제 #2
0
        public void AutoExplore_when_called_for_big_maze_finds_finish()
        {
            MazeGenerator generator = new MazeGenerator();
            var           maze      = generator.Generate(10, 10, new MazeGeneratorTest.RandomizerMock());

            var explorer = new Explorer(maze);

            var route = AutoExplorer.Explore(explorer).ToArray();

            Assert.IsTrue(explorer.IsFinish);
        }
예제 #3
0
        public void AutoExplore_when_called_for_randomly_generated_maze_finds_finish()
        {
            for (int i = 0; i < 10; i++)
            {
                MazeGenerator generator = new MazeGenerator();
                var           maze      = generator.Generate(10, 10, new Excelian.Maze.Generator.Randomizer());

                var explorer = new Explorer(maze);

                var route = AutoExplorer.Explore(explorer).ToArray();
                Assert.IsTrue(explorer.IsFinish);
            }
        }
예제 #4
0
        static void Main(string[] args)
        {
            MazeGenerator generator = new MazeGenerator();
            var           maze      = generator.Generate(20, 20, new Excelian.Maze.Generator.Randomizer());

            Console.WriteLine("Generated maze:");
            Console.WriteLine(maze.Render());
            var explorer = new Explorer(maze);

            Console.WriteLine("Route:");

            var route = AutoExplorer.Explore(explorer);

            Console.WriteLine(maze.RenderWithRoute(route));

            Console.ReadKey();
        }
예제 #5
0
        public void AutoExplore_when_called_for_minimalistic_maze2_returns_route()
        {
            var maze = Maze.Create(
                new MazeCellType[, ] {
                { MazeCellType.Wall, MazeCellType.Finish, MazeCellType.Wall },   // XXX
                { MazeCellType.Wall, MazeCellType.Space, MazeCellType.Wall },    // F.S
                { MazeCellType.Wall, MazeCellType.Start, MazeCellType.Wall }
            });                                                                  // XXX

            var explorer = new Explorer(maze);

            var route = AutoExplorer.Explore(explorer).ToArray();

            Assert.IsTrue(explorer.IsFinish);
            Assert.AreEqual(new Cell(2, 1), route[0]);
            Assert.AreEqual(new Cell(1, 1), route[1]);
            Assert.AreEqual(new Cell(0, 1), route[2]);
        }
예제 #6
0
        public void AutoExplore_when_called_for_maze_with_vertical_coridor()
        {
            var maze = Maze.Create(

                // ...
                // XSX
                // XFX
                new MazeCellType[, ] {
                { MazeCellType.Space, MazeCellType.Wall, MazeCellType.Wall },
                { MazeCellType.Space, MazeCellType.Start, MazeCellType.Finish },
                { MazeCellType.Space, MazeCellType.Wall, MazeCellType.Wall }
            });

            var explorer = new Explorer(maze);

            var route = AutoExplorer.Explore(explorer).ToArray();

            Assert.IsTrue(explorer.IsFinish);
        }