static void Main(string[] args) { //ForwardChaining fc = new ForwardChaining("green", "croaks&flies=>frog;chirps&sings=>canary;frog=>green;canary=>yellow;croaks;flies;"); //Console.WriteLine(fc.Execute()); string[] file = System.IO.File.ReadAllLines(String.Format(@"C:\Assignments\{0}", args[1])); string tell = file[1]; string ask = file[3]; if (args[0] == "TT") { TruthTable TT = new TruthTable(ask, tell); Console.WriteLine(TT.Execute()); } else if (args[0] == "FC") { ForwardChaining FC = new ForwardChaining(ask, tell); Console.WriteLine(FC.Execute()); } else if (args[0] == "BC") { BackwardsChaining BC = new BackwardsChaining(ask, tell); Console.WriteLine(BC.Execute()); } }
static void Main(string[] args) { // Usage: iengine method filename // Methods: TT / FC / BC // New Usage: // iengine method filename (Any triggers GUI) bool guiEnabled = false; if (args.Length < 1) { throw new Exception("Not enough arguments! Usage: iengine [Method] [Filename] [GUI: Yes/No]"); } if (args.Length > 2) { guiEnabled = true; } // Create modules and assign connections TextParser parser = new TextParser(args[1]); Console.WriteLine($"ASK: {parser.Ask} | TELL: {parser.Tell}"); KnowledgeBase KB; switch (args[0].ToLower()) { case "bc": KB = new BackwardChaining(parser.Ask, parser.Tell); break; case "fc": KB = new ForwardChaining(parser.Ask, parser.Tell); break; default: KB = new TruthTable(parser.Ask, parser.Tell); break; } Console.WriteLine($"KB Output: {KB.Execute()}"); if (guiEnabled) { SFMLView _view = new SFMLView(ref KB); while (!_view.IsFinished) { _view.Draw(); } _view.Close(); } }
static void Main(string[] args) { //Get Arguments from Command Line String[] arguments = Environment.GetCommandLineArgs(); string method = arguments[1]; //Name of the method to be used string filename = arguments[2]; //Name of the file to be used //FOR TESTING PURPOSES //string method = "TT"; //string filename = "test8.txt"; InferenceEngine IE; //InferenceEngine object to be used //Initiate the correct Inference Engine according to input paramaters switch (method) { //Truth Table checking case "TT": IE = new TruthTable(filename); break; //Forward Chaining case "FC": IE = new ForwardChaining(filename); break; //Backward Chaining case "BC": IE = new BackwardChaining(filename); break; default: IE = null; break; } //If Inference Engine Initiated, get results if (IE != null) { //If Inference Engine returns a result, print it out if (IE.getInference() == true) { Console.WriteLine("YES: " + IE.getResult()); } //If Inference engine doesn't return a result, print "NO" else { Console.WriteLine("NO"); } } }
/// <summary> /// A utility method to turn the users entered method into a method type /// </summary> /// <param name="Method">The method the user entered</param> /// <param name="output">a boolean representing if the user selected output or not</param> /// <returns>SearchClass</returns> private static SearchClass GetSearchType(string Method, bool output) { SearchClass SearchClass = new ForwardsChaining(); switch (Method.ToUpper()) { case "FC": case "FORWARDSCHAINING": break; case "BC": case "BACKWARDSCHAINING": SearchClass = new BackwardsChaining(); break; case "TT": case "TRUTHTABLE": case "TRUTHTABLECHECKING": SearchClass = new TruthTable(output); break; } return(SearchClass); }
static void Main(string[] args) { bool debugging = false; //DEBUG FLAG try { if (debugging)// debugging overide REMOVE { args = new[] { "BC", "./t1.txt" }; } if (args.Length != 2) { throw new System.ArgumentException("Wrong amount of arguments. Usage: Program.exe <method> <file path>"); } FileInput input = new FileInput(args[1]); Model model = new Model(); PropositionInterpreter propintr = new PropositionInterpreter(ref model); World MyWorld = new World(propintr.ParseProps(input.ReadFromFile()), model.Length); switch (args[0].ToUpper()) { case "TT": TruthTable Truthsolver = new TruthTable(model, MyWorld); Truthsolver.solve(); break; case "FC": ForwardChain forwardsolver = new ForwardChain(model, MyWorld); forwardsolver.Start(); break; case "BC": BackwardsChain backwardsolver = new BackwardsChain(model, MyWorld); backwardsolver.Start(); break; case "GRAPHICAL_TT": TruthTable GraphicalTruthsolver = new TruthTable(model, MyWorld); GraphicalTruthsolver.pretty_output(); break; default: throw new System.ArgumentException("Invaild method. Usage: Program.exe <method> <file path>"); } if (debugging)// debugging overide REMOVE { System.Console.ReadKey(); } } catch (Exception e) { System.IO.TextWriter errorWriter = Console.Error; errorWriter.WriteLine("Error: " + e.Message); if (debugging) // debugging overide REMOVE { errorWriter.WriteLine(Environment.NewLine + "In Object: " + e.StackTrace); //DEBUGGING } System.Environment.Exit(1); // something failed } }