///Public Static Methods //GenerateConsole method applys generation to grid and outputs result to console. public static void GenerateConsole(IGenerator _generator, int _width, int _height, out Grid _grid) { //Create a grid. Grid grid = new Grid(_width, _height); //Apply maze algorithm. _generator.Generate(grid); //Output result to console. MazeDisplay.ASCIIDisplay(grid); //Output the grid. _grid = grid; }
//GeneratePNG method applys generation to grid and outputs result to PNG file. public static void GenerateImage(IGenerator _generator, int _width, int _height, string _path, IImageEncoder _imageEncoder, out Grid _grid) { //Create a grid. Grid grid = new Grid(_width, _height); //Apply maze algorithm. _generator.Generate(grid); //Write result to file. MazeDisplay.ToImage(40, grid, RENDER_MODE.OUTLINE, _path, _imageEncoder); //Output the grid. _grid = grid; }
public ActionResult Display(int Id) { DL.Maze maze = MazeService.LireMaze(Id); MazeDisplay mazeDisplay = new MazeDisplay(); mazeDisplay.Id = maze.Id; mazeDisplay.Length = maze.Length; mazeDisplay.Width = maze.Width; mazeDisplay.Entree = maze.Entree; mazeDisplay.Sortie = maze.Sortie; List <DL.MazeTile> mazeTile = MazeService.LireMazeTile(Id); mazeDisplay.MazeTile = mazeTile; return(View(mazeDisplay)); }
//GenerateConsolePath method applys generation to grid, finds longest path between and outputs result to console. public static void GenerateConsolePath(IGenerator _generator, int _width, int _height, out DistanceGrid _grid) { //Create a grid. DistanceGrid grid = new DistanceGrid(_width, _height); //Apply maze algorithm. _generator.Generate(grid); //Find the distances. grid.FindDistances(grid[0, 0]); //Find the longest path. Cell startingCell = grid.FindLongestPath(); grid.distances = grid.distances.PathTo(startingCell); //Output result to console. MazeDisplay.ASCIIDisplay(grid); //Output the grid. _grid = grid; }
//GenerateColourPNG method applys generation to grid, finds longest path and outputs result to coloured png. public static void GenerateColourImage(IGenerator _generator, int _width, int _height, string _path, IImageEncoder _imageEncoder, out DistanceGrid _grid) { //Create a grid. DistanceGrid grid = new DistanceGrid(_width, _height); //Apply maze algorithm. _generator.Generate(grid); //Find the distances. grid.FindDistances(grid[0, 0]); //Find the longest path. Cell startingCell = grid.FindLongestPath(); grid.distances = grid.distances.PathTo(startingCell); grid.FindLongestPath(); //Write result to file. MazeDisplay.ToImage(40, grid, RENDER_MODE.COLOUR, _path, _imageEncoder); //Output the grid. _grid = grid; }
/// <summary> /// gets maze from server /// </summary> public void GetMazeInfo() { MazeInfo mazeInfo = new MazeInfo(40, 50, 36, 34, 8, 48, 36, 34, "00000000000100000000000100010001000000011111011111011111011111010111010101111101000001000100010001000101000001010001010101110101011101011101010111111101111101010001010100010100010101000001000100000001010111011101011101010111110101110111111101010001000100010001010000010001010000010101011101111101110101110111110101011101010000010000010001010001000000010001000101111101111101110111110111111101111101110100010001010100000001000100010001000101010101110101011111110111010111110101110101010001000100010001000001000000010000011101110111110101011111111101111111111101000101010001010100000000010101000001000101110101010111010111011101010101110101110001010101000001000100010101010101000101110101010111111111011101110101010111110100010001000101000001010000010101000000010111110111010101111101111111010111011101010001000001010001010000000001000001010101010111111101110101010111110111111101010001000100000000010001000001000100000101111111011111110111110111110101110101110100000101000001000001000100010100010000010111010101110111110111110111010111111111010000010001000001000001010001010000010101011111110111110111110101011101010101010101000100010000010100000100010101010101010101010111011111010111111101011101010101010100000100000100010000010100000100010111011111111111011111011101111111111101010000010001000100010001010000000000010101011111010101010101011101111111011111010001010001000101010100000101000001000001011101011111110111011111010101110101111100000101000001000001000001010100010100011101110101110111111101111101010111011101010100010101000000000100000101000100010101010111010111111111110111010111011101010001000100000100010001010001000101010101011111011111010101010111010111010101010100010100000100010001010001010101000101011101011101011111111101011101010111010101010001010100000000010001000101000101000101110101011101111111111101110111011111010100010101000100000100010100000101000001010111010111110111010101011101010101111100000001000000000100010000000101000000011111111111111111111111111111111111111111"); mazeDisplay = new MazeDisplay(mazeInfo); }