public void GetNeighbours_returns_2_Cells_for_corner_Cell() { var maze = new Maze(5, 5); var cornerCell = maze.Cells[0, 0]; var neighbours = maze.TestGetNeighbours(cornerCell); Assert.AreEqual(2, neighbours.Count); }
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); }
public void KnockWall_removes_east_wall_if_neighbour_is_east() { var current = new Cell(0, 0); var neighbour = new Cell(1, 0); var maze = new Maze(5, 5); maze.TestKnockWall(current, neighbour); Assert.IsFalse(current.AreAllWallsIntact, "Current has still all walls intact."); Assert.IsFalse(neighbour.AreAllWallsIntact, "Neighbour has still all walls intact."); Assert.IsFalse(current.HasEastWall, "Current still has east wall."); Assert.IsFalse(neighbour.HasWestWall, "Neighbour still has west wall."); }
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"); }
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); }
public void KnockWall_removes_north_wall_if_neighbour_is_north() { var current = new Cell(0, 1); var neighbour = new Cell(0, 0); var maze = new Maze(5, 5); maze.TestKnockWall(current, neighbour); Assert.IsFalse(current.AreAllWallsIntact, "Current has still all walls intact."); Assert.IsFalse(neighbour.AreAllWallsIntact, "Neighbour has still all walls intact."); Assert.IsFalse(current.HasNorthWall, "Current still has north wall."); Assert.IsFalse(neighbour.HasSouthWall, "Neighbour still has south wall."); }
public void Generate_creates_solvable_maze() { var maze = new Maze(5, 5); maze.Generate(1); Assert.IsTrue(maze.IsSolvable); }
public void Can_create_Maze_with_set_width_and_height() { var maze = new Maze(1,1); Assert.AreEqual(1, maze.Cells.GetLength(0)); Assert.AreEqual(1, maze.Cells.GetLength(1)); }
public void New_Maze_is_not_solvable() { var maze = new Maze(5, 5); Assert.IsFalse(maze.IsSolvable); }