/// <summary> /// Searches for a solved maze in the storage. /// </summary> /// <param name="name">Solution name</param> /// <returns>Solution if exists, else null</returns> public Solution <Position> SearchSolvedMaze(string name) { Solution <Position> solution; //Check if a solution with the given name exists in the dictionary. if (!SolvedMazes.ContainsKey(name)) { solution = null; } else { solution = SolvedMazes[name]; } return(solution); }
/// <summary> /// Solves a maze. /// </summary> /// <param name="mazeName">Maze name.</param> /// <param name="algorithmType">Algorithm type.</param> /// <returns>Solution.</returns> public Solution <Position> SolveMaze(string mazeName, int algorithmType) { //Check is solution already exists. if (SolvedMazes.ContainsKey(mazeName)) { return(SolvedMazes[mazeName]); } //Check if maze exists. if (!this.GenerateMazes.ContainsKey(mazeName)) { return(null); } Maze maze = GenerateMazes[mazeName]; //Solve maze. StatePool <Position> statePool = new StatePool <Position>(); SolutionAdapter ad = new SolutionAdapter(maze, statePool); ISearcher <Position> algorithm = this.AlgorithmFactory.CreateAlgorithm(algorithmType); return(algorithm.Search(ad)); }