static void Main(string[] args) { string nodes = ""; StringBuilder edges = new StringBuilder(); string algorithm = args[1].ToString().ToLower().Trim(); string file = args[0].ToString().Trim(); string problemType = readFile(file, ref nodes, ref edges); Console.WriteLine("--------------------------------------------------------------------------------"); Console.WriteLine("Running " + algorithm + " on " + file); if (problemType.Equals("monitor", StringComparison.OrdinalIgnoreCase)) { Dictionary <string, MonitorNode> nodeList = parseMonitorNodes(nodes); MonitorList monitor = new MonitorList(nodeList); parseMonitorEdges(edges.ToString(), monitor); Console.WriteLine(determineGoalState(runMonitorAlgorithm(algorithm, monitor))); } else if (problemType.Equals("aggregation", StringComparison.OrdinalIgnoreCase)) { Dictionary <string, AggregationNode> nodeList = parseAggregationNodes(nodes); parseAggregationEdges(edges.ToString(), nodeList); Console.WriteLine(determineGoalState(runAggregationAlgorithm(algorithm, nodeList))); } else if (problemType.Equals("pancakes", StringComparison.OrdinalIgnoreCase)) { PancakeNode pancakes = new PancakeNode(nodes); Console.WriteLine(determineGoalState(runPancakeAlgorithm(algorithm, pancakes))); } else { Console.WriteLine("Problem type not recognized."); endProgram(); } Console.ReadKey(); }
private static List <Tuple <string, double> > runPancakeAlgorithm(string algorithm, PancakeNode pancakes) { List <Tuple <string, double> > possiblePaths = new List <Tuple <string, double> >(); if (algorithm.Equals("bfs", StringComparison.OrdinalIgnoreCase)) { for (int i = 0; i < 100; i++) { possiblePaths.Add(pancakes.runBFS()); } } else if (algorithm.Equals("unicost", StringComparison.OrdinalIgnoreCase)) { possiblePaths.Add(pancakes.runUCS()); } else if (algorithm.Equals("iddfs", StringComparison.OrdinalIgnoreCase)) { possiblePaths.Add(pancakes.startDFS()); } else { Console.WriteLine("Algorithm not recognized."); endProgram(); } return(possiblePaths); }