public static int RunMapViewer(MapViewerOption option) { if (!File.Exists(option.Filename)) { Console.WriteLine("file not found!"); return(1); } var textMap = File.ReadAllText(option.Filename); if (!option.Window) { try { Console.WriteLine(textMap); return(0); } catch (Exception ex) { Console.WriteLine(ex.Message); return(1); } } MapViewWindow.OpenGlWindow(textMap, option.BlockSize); return(0); }
static int _runFinder(IFinder finder, IHeuristic h, IMap map, bool window, bool noshow, int blocksize, int sleep) { if (!noshow) { if (sleep > 0) { finder.SleepUITimeInMs = sleep; } var viewer = window ? ViewerFactory.GetOpenGlViewerImplementation(blocksize) : ViewerFactory.GetConsoleViewerImplementation(); viewer.SetFinder(finder); viewer.Run(map, h); } else { if (finder.Find(map, h)) { var path = map.GetPath(); AbstractViewer.ShowEndLog(finder, path, new Pathfinder.Abstraction.FinderEventArgs { Finded = true, GridMap = map, ExpandedNodesCount = map.GetMaxExpandedNodes(), PassedTimeInMs = finder.GetProcessedTime(), Step = 0 }); var result = FileTool.GetTextRepresentation(map, false, path); if (!window) { Console.WriteLine(result); } else { MapViewWindow.OpenGlWindow(result, blocksize); } } else { Console.WriteLine("Cant find a path"); } } return(0); }