/// <summary> /// Solves the maze. /// </summary> /// <param name="name">The name.</param> /// <param name="typeAlgo">The type algo.</param> /// <returns></returns> public static SolveInfo SolveMaze(string name, string typeAlgo) { Maze maze = singleplayerMazeList[name]; MazeAdapter mazeSearchable = new MazeAdapter(maze); // Isearchable var temp = new CompareStates <Position>(); Solution <Position> solution = null; int nodesEvaluated = 0; if (solutionsList.ContainsKey(maze)) { return(solutionsList[maze]); } // find solution of the maze: switch (typeAlgo) { case "0": BFS <Position> bfs = new BFS <Position>(temp); solution = bfs.Search(mazeSearchable); nodesEvaluated = bfs.GetNumberOfNodesEvaluated(); break; case "1": DFS <Position> dfs = new DFS <Position>(temp); solution = dfs.Search(mazeSearchable); nodesEvaluated = dfs.GetNumberOfNodesEvaluated(); break; } SolveInfo solveInfo = new SolveInfo(nodesEvaluated, solution); // add the solution to the solutions dictionary solutionsList.Add(maze, solveInfo); return(solveInfo); }
public DataNode(string nameLeft, string pathLeft, long sizeLeft, DateTime modifiedLeft, string nameRight, string pathRight, long sizeRight, DateTime modifiedRight , CompareStates compareState, int level, bool expanded, ItemType type) { MChildren = new List <DataNode>(16); _mNameLeft = nameLeft; _mPathLeft = pathLeft; _mSizeLeft = sizeLeft; _mModifiedLeft = modifiedLeft; _mNameRight = nameRight; _mPathRight = pathRight; _mSizeRight = sizeRight; _mModifiedRight = modifiedRight; _mCompareState = compareState; _mLevel = level; _mType = type; _mExpanded = expanded; _mFileType = string.Empty; _mSelection = Selection.None; _mPropertiesLeft = string.Empty; _mPropertiesRight = string.Empty; }
/// <summary> /// Compares the solvers. /// </summary> /// <param name="rows">The rows.</param> /// <param name="cols">The cols.</param> private static void CompareSolvers(int rows, int cols) { DFSMazeGenerator dfsMazeGenerator = new DFSMazeGenerator(); Maze maze = dfsMazeGenerator.Generate(rows, cols); MazeAdapter mazeSearchable = new MazeAdapter(maze); // Isearchable Console.WriteLine(maze.ToString()); var temp = new CompareStates <Position>(); // BFS search: BFS <Position> bfs = new BFS <Position>(temp); Solution <Position> bfsSol = bfs.Search(mazeSearchable); // DFS search DFS <Position> dfs = new DFS <Position>(temp); Solution <Position> dfsSol = dfs.Search(mazeSearchable); Console.WriteLine("BFS" + bfs.GetNumberOfNodesEvaluated()); Console.WriteLine("DFS" + dfs.GetNumberOfNodesEvaluated()); }