예제 #1
0
        public void Generate_chooses_random_starting_Cell()
        {
            var maze = new Maze(5, 5);
            maze.Generate(1);
            var startingCell1 = maze.Start;
            maze.Generate(2);
            var startingCell2 = maze.Start;

            Assert.AreNotEqual(startingCell1.X, startingCell2.X);
            Assert.AreNotEqual(startingCell1.Y, startingCell2.Y);
        }
예제 #2
0
        public ContentResult Generate(int width, int height, string perfect)
        {
            var maze = new Maze(width, height);
            maze.Generate(DateTime.Now.Millisecond, perfect == "on" | string.IsNullOrEmpty(perfect));

            SaveMaze(maze);

            var json = JsonConvert.SerializeObject(maze);
            SaveMazeJson(json);

            playerSavingService.ResetCurrentSavedPlayerState();

            return Content(json, "application/json");
        }
예제 #3
0
        public void Generate_creates_Maze_with_no_cells_having_all_walls_intakt()
        {
            var maze = new Maze(5, 5);
            var foundCellWithAllWallsIntakt = false;
            maze.Generate(1);

            for (var x = 0; x < 5; x++)
            {
                if (foundCellWithAllWallsIntakt)
                {
                    break;
                }
                for (var y = 0; y < 5; y++)
                {
                    if (!maze.Cells[x, y].AreAllWallsIntact) continue;
                    foundCellWithAllWallsIntakt = true;
                    break;
                }
            }
            Assert.IsFalse(foundCellWithAllWallsIntakt);
        }
예제 #4
0
 public void Generate_creates_solvable_maze()
 {
     var maze = new Maze(5, 5);
     maze.Generate(1);
     Assert.IsTrue(maze.IsSolvable);
 }