private static void SolveSheepAndWolves() { var side1 = new StateSide(0, 0, false); var side2 = new StateSide(3, 3, true); var initialState = new SheepAndWolvesState(side1, side2); var breadthFirstSolution = SearchState.Search(initialState, frontier => frontier[0]); foreach (var solutionState in breadthFirstSolution) { Console.WriteLine("Breadth First Search:"); Console.WriteLine("{S W B | S W B}"); Console.WriteLine(initialState); Console.WriteLine(AbstractState.BuildSequence(solutionState)); } var depthFirstSolution = SearchState.Search(initialState, frontier => frontier[frontier.Count - 1]); foreach (var solutionState in depthFirstSolution) { Console.WriteLine("Depth First Search:"); Console.WriteLine("{S W B | S W B}"); Console.WriteLine(initialState); Console.WriteLine(AbstractState.BuildSequence(solutionState)); } }
private static void SolveMeasureByJars() { var initialState = new JarsState(0, 0, 0); var breadthFirstSolution = SearchState.Search(initialState, frontier => frontier[0]); foreach (var solutionState in breadthFirstSolution) { Console.WriteLine("Hurray !!!"); Console.WriteLine(AbstractState.BuildSequence(solutionState)); } var depthFirstSolution = SearchState.Search(initialState, frontier => frontier[frontier.Count - 1]); foreach (var solutionState in depthFirstSolution) { Console.WriteLine("Hurray !!!"); Console.WriteLine(AbstractState.BuildSequence(solutionState)); } }