private static MDE.Point Convert(this Base.Point position) { return((position is MDE.Point p) ? p : new MDE.Point() { X = position.X, Y = position.Y, Z = position.Z }); }
public void FindShortestPath(string destinationPath, Base.Point destinationPoint) { Node previousNode = null; try { previousNode = _graph[destinationPoint.Key]; } catch (KeyNotFoundException) { throw new InvalidDestinationPoint(destinationPoint); } Bitmap mazeImage = new Bitmap(_mazeImageFullPath); while (previousNode != null) { mazeImage.SetPixel(previousNode.Point.X, previousNode.Point.Y, Color.Red); previousNode = previousNode.PreviousNode; } mazeImage.Save(destinationPath); Console.WriteLine("Shortest path found!"); Process process = new Process(); process.StartInfo.FileName = @"C:\Windows\system32\mspaint.exe"; process.StartInfo.Arguments = destinationPath; process.Start(); }
private static void SolveMaze(Base.Point source, Base.Point destination, string sourceFile, string destinationFile) { DijkstraPathFinder dijkstraPathFinder = new DijkstraPathFinder(sourceFile, source); dijkstraPathFinder.PrepareGraph(); dijkstraPathFinder.FindShortestPath(destinationFile, destination); }
public DijkstraPathFinder(string mazeImageFullPath, Base.Point sourcePoint) { _sourcePoint = sourcePoint; _graph = new GraphGenerator(mazeImageFullPath).GenerateGraph(sourcePoint); Console.WriteLine("Graph Generation Completed"); _mazeImageFullPath = mazeImageFullPath; }