Exemplo n.º 1
0
        /**
         * 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);
        }
Exemplo n.º 2
0
 /**
  * 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());
 }
Exemplo n.º 3
0
 public void SetBFSSearch(AlgorithmResults bfsSearch)
 {
     this.bfsSearch = bfsSearch;
 }
Exemplo n.º 4
0
 public void SetDijkstra(AlgorithmResults dijkstra)
 {
     this.dijkstra = dijkstra;
 }
Exemplo n.º 5
0
 public void SetaStar(AlgorithmResults aStar)
 {
     this.aStar = aStar;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes the three algorithm results.
 /// </summary>
 public ExperimentResults()
 {
     aStar     = new AlgorithmResults();
     dijkstra  = new AlgorithmResults();
     bfsSearch = new AlgorithmResults();
 }