コード例 #1
0
ファイル: Model.cs プロジェクト: nevow/ex1ap2
        /// <summary>
        /// solve a maze
        /// </summary>
        /// <param name="name">the name of the maze</param>
        /// <param name="searcher">the algorithem to solve with</param>
        /// <returns>the solution to the maze</returns>
        public MazeSolution SolveMaze(string name, SearchAlgo searcher)
        {
            // checks if the maze exist
            if (!singlePlayerMazes.ContainsKey(name))
            {
                return(null);
            }
            // checks if the solution exist
            if (singlePlayerSolved.ContainsKey(name))
            {
                return(singlePlayerSolved[name]);
            }
            // solve the maze and return the solution
            Maze         maze        = singlePlayerMazes[name];
            MazeAdapter  mazeAdapter = new MazeAdapter(maze);
            MazeSolution ms          = new MazeSolution(searcher(mazeAdapter), maze.Name);

            // save the current solution
            singlePlayerSolved.Add(name, ms);
            return(ms);
        }
コード例 #2
0
 List <Point> IVisionModel.GetPathTo(TypeTile[] targets, int range)
 {
     return(SearchAlgo.DijkstraPath(_visionMap, Position, targets, range));
 }