Exemplo n.º 1
0
        public JObject Solve(string name, int algo)
        {
            MazeGame game = Multi.ContainsKey(name) ? Multi[name] : Single[name];

            if (game.Solution == null)
            {
                ISearcher <Position> searcher = algo == 0 ? (ISearcher <Position>)
                                                new BFS <Position, int>((s1, s2) => 1, (i, j) => i + j) :
                                                new DFS <Position>();
                SearchableMaze smaze = new SearchableMaze(game.Maze);
                game.Solution          = MazeSolution.FromSolution(searcher.Search(smaze));
                game.Solution.MazeName = name;
            }

            return(JObject.Parse(game.Solution.ToJSON()));
        }