public void ShouldFail() { _states["A"].NextStatesList = new[] { _states["B"], _states["C"] }; _states["B"].NextStatesList = new[] { _states["D"] }; _states["C"].NextStatesList = new[] { _states["E"] }; _states["E"].NextStatesList = new[] { _states["F"] }; var problem = new DummyProblem(_states["A"]); var dls = new DepthLimitedSearch <DummyProblemState>(10); var result = dls.Search(problem).ToList(); Assert.Empty(result); Assert.Equal(false, dls.IsCutoff); }
public static void UninformedAlgorithms() { Console.WriteLine("Welcome\nARTIFICIAL INTELLIGENCE SEARCH ALGORITHMS"); ShowOptions(); var input = Console.ReadLine(); int res = 1; while (int.TryParse(input, out res) == false) { ShowOptions(); input = Console.ReadLine(); } Node <string> startNode = null; Node <string> goalNode = null; switch (Convert.ToInt32(input)) { case 1: { startNode = GetRootNode(); goalNode = GetGoalNode(); Console.WriteLine("BREADTH FIRST SEARCH IMPLEMENTATION------------"); var bfs = new BreadthFirstSearch <string>(goalNode, startNode); bfs.Search(); } break; case 2: { startNode = GetRootNode(); goalNode = GetGoalNode(); Console.WriteLine("DEPTH FIRST SEARCH IMPLEMENTATION------------"); var dfs = new DepthFirstSearch <string>(goalNode, startNode); dfs.Search(); } break; case 3: { startNode = GetRootNode(); goalNode = GetGoalNode(); Console.WriteLine("\nEnd\n"); Console.WriteLine("ITERATIVE DEEPENING SEARCH IMPLEMENTATION------------"); var ids = new IterativeDeepingSearch <string>(goalNode, startNode); ids.Search(); } break; case 4: { startNode = GetRootNode(); goalNode = GetGoalNode(); Console.WriteLine("DEPTH LIMITED SEARCH IMPLEMENTATION------------"); Console.Write("Enter limit to search: "); var limit = int.Parse(Console.ReadLine()); var dls = new DepthLimitedSearch <string>(goalNode, startNode, limit); dls.Search(); } break; case 5: { startNode = GetRootNode(); goalNode = GetGoalNode(); Console.WriteLine("Enter the cost for the nodes"); foreach (var node in Nodes) { Console.Write($"Enter cost for node: {node.NodeName}: "); node.Cost = double.Parse(Console.ReadLine()); } Console.WriteLine("UNIFORM COST SEARCH IMPLEMENTATION------------"); var ucs = new UniformCostSearch <string>(goalNode, startNode); ucs.Search(); } break; case 6: { startNode = GetRootNode(); goalNode = GetGoalNode(); Console.WriteLine("BIDIRECTIONAL SEARCH IMPLEMENTATION------------"); var bidi = new BidirectionalSearch <string>(goalNode, startNode); bidi.Search(); } break; default: ShowOptions(); break; } }