/// <summary> /// Solves the maze. /// </summary> /// <param name="name">The name.</param> /// <param name="algorithm">The algorithm.</param> /// <returns></returns> public /*Solution<Position>*/ List <string> SolveMaze(string name, int algorithm) { SingleGame game = cash.GetSingleGame(name); if (game != null) { //Solution<Position> solution = cash.GetSolution(name); /*Solution<Position> solution = game.Solution; * if (!(solution == null)) * { * return solution; * }*/ //Maze maze = cash.GetMaze(name); Maze maze = game.Maze; ISearcher <Position> searcher = null; if (algorithm == 0) { searcher = new BFS <Position>(); } else if (algorithm == 1) { searcher = new DFS <Position>(); } MazeAdapter <Position> mazeAdapter = new MazeAdapter <Position>(maze); Solution <Position> solution = searcher.Search(mazeAdapter); //cash.AddSolution(name, solution); //game.Solution = solution; return(this.GetSolutionString(solution.List)); //solution; } return(null); }
/// <summary> /// Initializes a new instance of the <see cref="Controller"/> class. /// </summary> /*public MazeCash () * { * /*model = new Model(this); * commands = new Dictionary<string, ICommand>(); * commands.Add("generate", new GenerateMazeCommand(model)); * commands.Add("solve", new SolveMazeCommand(model)); * commands.Add("start", new StartGameCommand(model)); * commands.Add("join", new JoinGameCommand(model)); * commands.Add("list", new ListCommand(model)); * commands.Add("play", new PlayGameCommand(model)); * commands.Add("close", new CloseGameCommand(model)); * //mazes = new Dictionary<string, Maze>(); * //solutions = new Dictionary<string, Solution<Position>>(); * //games = new Dictionary<string, MultiGame>(); * singleGames = new Dictionary<string, SingleGame>(); * multiGames = new Dictionary<string, MultiGame>(); * }*/ /// <summary> /// Executes the command. /// </summary> /// <param name="commandLine">The command line.</param> /// <param name="client">The client.</param> /// <returns></returns> /*public string ExecuteCommand (string commandLine, ClientNotifier client) //TcpClient client) * { * string[] arr = commandLine.Split(' '); * string commandKey = arr[0]; * if (!commands.ContainsKey(commandKey)) * { * client.ToSend = true; * client.ChangeToClose = true; * return "Command not found"; * } * string[] args = arr.Skip(1).ToArray(); * ICommand command = commands[commandKey]; * return command.Execute(args, client); * }*/ public void AddSingleGame(string name, SingleGame game) { if (singleGames.ContainsKey(name)) { singleGames[name] = game; return; } singleGames.Add(name, game); }