/// <summary> /// Solves this instance. /// </summary> public void Solve() { string cmd = SettingsManager.ReadSetting(SettingName.SearchAlgorithm); string ip = SettingsManager.ReadSetting(SettingName.IP); int port = int.Parse(SettingsManager.ReadSetting(SettingName.Port)); Communicator c = new Communicator(ip, port); cmd = string.Format("solve {0} {1}", Maze.Name, cmd); c.SendMessage(cmd); cmd = c.ReadMessage(); c.Dispose(); Message m = Message.FromJSON(cmd); if (m.MessageType != MessageType.CommandResult) { return; } CommandResult res = CommandResult.FromJSON(m.Data); if (res.Command != Command.Solve) { return; } solving = true; MazeSolution sol = MazeSolution.FromJSON(res.Data); new Task(() => AnimateSolution(sol)).Start(); }
/// <summary> /// Solves this instance. /// </summary> public void Solve() { Connect(); Writer.WriteLine("solve {0} {1}", maze.Name, defaultSearchAlgorithm); Writer.Flush(); string answer = Reader.ReadLine(); answer = answer.Replace("@", Environment.NewLine); Disconnect(); MazeSolution ms = MazeSolution.FromJSON(answer); RunSolveTask(ms.SolutionString); }