/// <summary> /// Searches for a solution to the provided problem using the algorithm of the derived class. /// </summary> /// <param name="problem">The <see cref="SearchProblem"/> to be searched.</param> /// <param name="heuristic">The <see cref="IHeuristic"/> to use when evaluating states.</param> /// <returns>An <see cref="Array"/> of <see cref="State"/>s that will lead to the solution or null if no solution is possible.</returns> public State[] Search(SearchProblem problem, IHeuristic heuristic = null) { if (heuristic == null) { heuristic = new NullHeuristic(); } this.StartStopwatch(); State[] result = this.RunSearch(problem, heuristic); this.StopStopwatch(); return(result); }
private Heuristic SelectProperHeuristic() { if (MustUseHeuristic()) { if (checkBoxDiagonalMove.Checked) { return(DiagonalDistanceHeuristic.GetDiagonalDistanceHeuristic()); } else { return(ManhattanDistanceHeuristic.GetManhattanDistanceHeuristic()); } } else { return(NullHeuristic.GetNullHeuristic()); } }