/** * Searches a file for the best path using three algorithms. The solutions * can be shown on screen. * @param filename The file (without extension) to be searched. * @param showSolutions Indicates if solutions should be shown on screen. * @return All relevant statistics for the three experiments. */ public static ExperimentResults search(eTileType[,] map, String filename) { ExperimentResults info = new ExperimentResults(); // Dijkstra Dijkstra dijkstraAlgorithm = new Algorithm.Dijkstra(new TileWorld.TileWorld(map)); AlgorithmResults dijkstra = dijkstraAlgorithm.run(); info.setDijkstra(dijkstra); saveImage(filename + "_dijkstra", dijkstraAlgorithm.getMap()); // A* AStar aStarAlgorithm = new AStar(new TileWorld.TileWorld(map)); AlgorithmResults aStar = aStarAlgorithm.run(); info.setaStar(aStar); saveImage(filename + "_aStar", aStarAlgorithm.getMap()); // BFS Search BFS bfsAlgorithm = new BFS(new TileWorld.TileWorld(map)); AlgorithmResults bfsSearch = bfsAlgorithm.run(); info.setBFSSearch(bfsSearch); saveImage(filename + "_bfs", bfsAlgorithm.getMap()); return(info); }
/** * Prints the results of one algorithm on System.out. * * @param algorithmString Name of the algorithm used (A*, Dijkstra, ...). * @param info Results of the algorithm. */ private static void printAlgorithmResult(String algorithmString, AlgorithmResults info) { Console.WriteLine(algorithmString); if (info == null) { Console.WriteLine("No results found."); return; } Console.WriteLine("#nodes: " + info.getNodesExpanded()); Console.WriteLine("#path cost: " + info.getBestPathCost()); }
public void SetBFSSearch(AlgorithmResults bfsSearch) { this.bfsSearch = bfsSearch; }
public void SetDijkstra(AlgorithmResults dijkstra) { this.dijkstra = dijkstra; }
public void SetaStar(AlgorithmResults aStar) { this.aStar = aStar; }
/// <summary> /// Initializes the three algorithm results. /// </summary> public ExperimentResults() { aStar = new AlgorithmResults(); dijkstra = new AlgorithmResults(); bfsSearch = new AlgorithmResults(); }