Example #1
0
        public IHttpActionResult SolveMaze(SolveRequest solveRequest)
        {
            string searchAlgo = "1";

            if (solveRequest.SearchAlgo == "BFS")
            {
                searchAlgo = "0";
            }
            SolveInfo       solveInfo       = Model.SolveMaze(solveRequest.Name, searchAlgo);
            SolutionAdapter solutionAdapter = new SolutionAdapter(solveInfo.Solution);
            string          strSolution     = solutionAdapter.CreateString();

            JObject solutionObj = new JObject();

            solutionObj["Name"]     = solveRequest.Name;
            solutionObj["Solution"] = strSolution;

            return(Ok(solutionObj));
        }
Example #2
0
        /// <summary>
        /// Executes the specified arguments.
        /// </summary>
        /// <param name="args">The arguments.</param>
        /// <param name="client">The client.</param>
        /// <returns></returns>
        public ConnectionInfo Execute(string[] args, TcpClient client = null)
        {
            string name = args[0];
            string algo = args[1];

            SolveInfo       solveInfo       = model.SolveMaze(name, algo);
            SolutionAdapter solutionAdapter = new SolutionAdapter(solveInfo.Solution);
            string          strSolution     = solutionAdapter.CreateString();

            JObject solutionObj = new JObject();

            solutionObj["Name"]           = name;
            solutionObj["Solution"]       = strSolution;
            solutionObj["NodesEvaluated"] = solveInfo.NodesEvaluated;

            ConnectionInfo connectionInfo = new ConnectionInfo();

            connectionInfo.Answer          = solutionObj.ToString();
            connectionInfo.CloseConnection = true;

            return(connectionInfo);
        }