Пример #1
0
        /// <summary>
        /// Froms the json.
        /// </summary>
        /// <param name="str">The string.</param>
        /// <returns></returns>
        public static MazeSolution FromJSON(string str)
        {
            MazeSolution ms  = new MazeSolution();
            JObject      obj = JObject.Parse(str);

            ms.GameName       = (string)obj["Name"];
            ms.SolutionString = (string)obj["Solution"];
            ms.EvaluatedNodes = (int)obj["NodesEvaluated"];
            return(ms);
        }
Пример #2
0
        /// <summary>
        /// Converts the solution of maze.
        /// </summary>
        /// <param name="s">The solution of the maze.</param>
        /// <param name="name">The name of the maze.</param>
        /// <returns>the maze solution</returns>
        private MazeSolution ConvertSolution(Solution <Position, int> s, string name)
        {
            List <Position> positionList = new List <Position>();

            foreach (State <Position, int> state in s.GetSolution())
            {
                positionList.Add(state.StateValue);
            }

            MazeSolution ms = new MazeSolution()
            {
                EvaluatedNodes = s.GetEvaluatedNodes(),
                Solution       = positionList,
                GameName       = name
            };

            return(ms);
        }