public static void Main() { Console.OutputEncoding = Encoding.UTF8; Console.WriteLine("Podaj wymiar szachownicy: "); var size = byte.Parse(Console.ReadLine()); var problemHetmans = new Hetmans(size); Node <byte[]> result; Console.WriteLine("\nRozwiązywanie za pomocą Stosu..."); var stackSolution = new StackFringe <Node <byte[]> >(); var stoper = Stopwatch.StartNew(); result = TreeSearch <byte[]> .TreeSearchMethod(problemHetmans, stackSolution, Method.Stack); stoper.Stop(); DisplaySolution(problemHetmans, result, stoper); stoper.Reset(); TreeSearch <byte[]> .CountOfSteps = 0; Console.WriteLine("\nRozwiązywanie za pomocą kolejki..."); var queueSolution = new QueueFringe <Node <byte[]> >(); stoper.Start(); result = TreeSearch <byte[]> .TreeSearchMethod(problemHetmans, queueSolution, Method.Queue); stoper.Stop(); DisplaySolution(problemHetmans, result, stoper); stoper.Reset(); TreeSearch <byte[]> .CountOfSteps = 0; Console.WriteLine("\nRozwiązywanie za pomocą BestFirstSearch (ilość konfliktów)..."); var priorityQueueSolution = new PriorityQueueFringe <Node <byte[]> >(); stoper.Start(); result = TreeSearch <byte[]> .TreeSearchMethod(problemHetmans, priorityQueueSolution, Method.PriorityQueue); stoper.Stop(); DisplaySolution(problemHetmans, result, stoper); stoper.Reset(); TreeSearch <byte[]> .CountOfSteps = 0; Console.WriteLine("\nRozwiązywanie za pomocą A* (ilości konfliktów + ilość kroków)..."); var AStarSolution = new PriorityQueueFringe <Node <byte[]> >(); stoper.Start(); result = TreeSearch <byte[]> .TreeSearchMethod(problemHetmans, AStarSolution, Method.AStar); stoper.Stop(); DisplaySolution(problemHetmans, result, stoper); TreeSearch <byte[]> .CountOfSteps = 0; }
public static void DisplaySolution(Hetmans problemHetmans, Node <byte[]> result, Stopwatch stoper) { Console.Beep(); problemHetmans.ShowState(problemHetmans.InitialState); if (result == null) { Console.WriteLine("\nBrak Rozwiązań!"); } else { Console.WriteLine("Rozwiązanie:"); ShowState(result.StateOfNode); Console.WriteLine("Czas poszukiwania rozwiązania: " + stoper.Elapsed); //zmienna z czasem); Console.WriteLine("Liczba kroków do znalezienia rozwiązania: " + TreeSearch <byte[]> .CountOfSteps); Console.WriteLine("\nLiczba kroków rozwiązania: " + result.StepsForSolution); Console.WriteLine("---------------------------------------------------------------------------"); } }