예제 #1
0
		private SearchAlgorithmResult SearchShortestPath(Guid origin, Guid destination, SearchAlgorithmParameters searchParameters)
		{
			var graph = new Graph(_context);
			graph.PopulateGraph(searchParameters.SearchOptions);

			var search = SearchAlgorithmFactory.GetSearchAlgorithm(searchParameters.SearchAlgorithm);
			return search.Search(graph, origin, destination, searchParameters.SearchOptionPath);
		}
예제 #2
0
 public Model()
 {
     this.mazeGenerator          = new DFSMazeGenerator();
     this.algorithmFactory       = new SearchAlgorithmFactory <Position>();
     this.singlePlayerMazes      = new Dictionary <string, Maze>();
     this.multiPlayerMazes       = new Dictionary <string, Maze>();
     this.joinableMazes          = new Dictionary <string, Maze>();
     this.activeMultiPlayerMazes = new Dictionary <string, Maze>();
 }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Model"/> class.
 /// </summary>
 /// <param name="icontroller">The icontroller.</param>
 public Model(IController icontroller)
 {
     this.icontroller            = icontroller;
     this.mazeGenerator          = new DFSMazeGenerator();
     this.algorithmFactory       = new SearchAlgorithmFactory <Position>();
     this.singlePlayerMazes      = new Dictionary <string, Maze>();
     this.mazeSolutions          = new Dictionary <string, Solution <Position> >();
     this.multiPlayerMazes       = new Dictionary <string, Maze>();
     this.joinableMazes          = new Dictionary <string, MazeGame>();
     this.activeMultiPlayerMazes = new Dictionary <string, MazeGame>();
     this.playersAndGames        = new Dictionary <Player, MazeGame>();
 }
예제 #4
0
파일: Program.cs 프로젝트: yoav8000/Ex1Ap2
        static void Main(string[] args)
        {
            DFSMazeGenerator mazeGen = new DFSMazeGenerator();
            Maze             maze    = mazeGen.Generate(50, 50);

            Console.WriteLine(maze.ToString());
            MazeAdapter mazeAdapter = new MazeAdapter(maze);
            SearchAlgorithmFactory <Position> factory = new SearchAlgorithmFactory <Position>();
            ISearcher <Position> bfsSearcher          = factory.GetSearchAlgorithm("bfs");
            ISearcher <Position> dfsSearcher          = factory.GetSearchAlgorithm("dfs");
            Solution <Position>  solution             = bfsSearcher.Search(mazeAdapter);
            Solution <Position>  solution1            = dfsSearcher.Search(mazeAdapter);

            Console.WriteLine("the bfs solved the maze int {0}", bfsSearcher.GetNumberOfNodesEvaluated());
            Console.WriteLine("the dfs solved the maze int {0}", dfsSearcher.GetNumberOfNodesEvaluated());
            Console.ReadKey();
        }
예제 #5
0
        /// <summary>
        /// Mains the specified arguments.
        /// </summary>
        /// <param name="args">The arguments.</param>
        static void Main(string[] args)
        {
            DFSMazeGenerator mazeGen = new DFSMazeGenerator();
            Maze             maze    = mazeGen.Generate(50, 50);

            Console.WriteLine(maze.ToString());
            MazeAdapter mazeAdapter = new MazeAdapter(maze);
            SearchAlgorithmFactory <Position> factory = new SearchAlgorithmFactory <Position>();
            ISearcher <Position> bfsSearcher          = factory.GetSearchAlgorithm("bfs");
            ISearcher <Position> dfsSearcher          = factory.GetSearchAlgorithm("dfs");
            Solution <Position>  solution1            = bfsSearcher.Search(mazeAdapter);
            SolutionAdapter      solutionAd1          = new SolutionAdapter(solution1, "bla");
            Solution <Position>  solution2            = dfsSearcher.Search(mazeAdapter);
            SolutionAdapter      solutionAd2          = new SolutionAdapter(solution2, "bla");
            string a = solutionAd1.ToJson();

            Console.WriteLine("the bfs solved the maze int {0}", solution1.NodesEvaluated);
            Console.WriteLine("the dfs solved the maze int {0}", solution2.NodesEvaluated);
            Console.ReadKey();
        }
예제 #6
0
        static void Main(string[] args)
        {
            string json = @"{
                'Name': 'mymaze',
                'Maze':                '0001010001010101110101010000010111111101000001000111010101110001010001011111110100000000011111111111',
                'Rows': 10,
                'Cols': 10,
                'Start': {
                    'Row': 0,
                    'Col': 4
                },
                'End': {
                    'Row': 0,
                    'Col': 0
                }
            }";

            Maze maze = Maze.FromJSON(json);

            DFSMazeGenerator mazeGen = new DFSMazeGenerator();

            // Maze maze = mazeGen.Generate(10,10);
            Console.WriteLine(maze.ToString());
            MazeAdapter mazeAdapter = new MazeAdapter(maze);
            SearchAlgorithmFactory <Position> factory = new SearchAlgorithmFactory <Position>();
            ISearcher <Position> bfsSearcher          = factory.GetSearchAlgorithm("bfs");
            ISearcher <Position> dfsSearcher          = factory.GetSearchAlgorithm("dfs");
            Solution <Position>  solution1            = bfsSearcher.Search(mazeAdapter);
            SolutionAdapter      solutionAd1          = new SolutionAdapter(solution1, "bla");
            Solution <Position>  solution2            = dfsSearcher.Search(mazeAdapter);
            SolutionAdapter      solutionAd2          = new SolutionAdapter(solution2, "bla");

            string a = solutionAd1.ToJson();


            Console.WriteLine("the bfs solved the maze int {0}", solution1.NodesEvaluated);
            Console.WriteLine("the dfs solved the maze int {0}", solution2.NodesEvaluated);
            Console.ReadKey();
        }