mirror of
https://github.com/Stone-Red-Code/Maze.git
synced 2026-09-04 00:56:11 +02:00
31 lines
942 B
C#
31 lines
942 B
C#
using Maze;
|
|
using Maze.Nodes;
|
|
using Maze.Solvers;
|
|
using Maze.Utlis;
|
|
|
|
using Stone_Red_Utilities.ConsoleExtentions;
|
|
|
|
MazeParser parser = new MazeParser();
|
|
MazePrinter printer = new MazePrinter();
|
|
IMazeSolver<DfsNode> solver = new DepthFirstSearchMazeSolver();
|
|
|
|
try
|
|
{
|
|
DfsNode[,] maze = parser.FromFile("input.txt", out DfsNode startNode);
|
|
|
|
if (Console.WindowHeight < maze.GetLength(0) || Console.WindowWidth < maze.GetLength(1))
|
|
{
|
|
ConsoleExt.WriteLine("Console window size too small. Visualizing the maze may cause errors!", ConsoleColor.Red);
|
|
ConsoleExt.Pause(true, "Press ENTER to continue or CTRL+C to exit the program.");
|
|
}
|
|
|
|
List<DfsNode> solution = solver.Solve(startNode, maze, GraphicsMode.Colored);
|
|
|
|
printer.PrintColored(maze, solution, redrawAll: true);
|
|
|
|
ConsoleExt.WriteLine("Done", ConsoleColor.Green);
|
|
}
|
|
catch (MazeException e)
|
|
{
|
|
ConsoleExt.WriteLine(e.Message, ConsoleColor.Red);
|
|
} |