Пример #1
0
        private bool GoalVerify(IKnowledge obj, EqGoal eqGoal, out string msg, out object output)
        {
            msg    = AGTutorMessage.VerifyWrong;
            output = null;

            List <Tuple <object, object> > trace = null;

            var agPropExpr = new AGPropertyExpr(obj.Expr, eqGoal);

            agPropExpr.IsSelected = true;
            agPropExpr.GenerateSolvingTrace();
            trace = agPropExpr.AutoTrace;

            BehaviorGraphNode node;

            if (trace == null || trace.Count == 0)
            {
                node = UserGraph.UpdateSolvingCache(agPropExpr);
                //node = UserGraph.SearchInnerLoopNode(eqGoal);

                if (node == null)
                {
                    return(false);
                }
            }
            if (trace != null)
            {
                bool matchResult = UserGraph.Match(trace);
                if (!matchResult)
                {
                    return(false);
                }
                //insert nodes
                UserGraph.Insert(trace);
                CurrentStateNode = UserGraph.SearchInnerLoopNode(obj); //update _currentStateNode;
            }
            else
            {
                CurrentStateNode = UserGraph.SearchInnerLoopNode(eqGoal);
            }

            /* var nextTuple1 = UserGraph.SearchNextInnerLoopNode(CurrentStateNode);
             * if (nextTuple1 == null) // query-end
             * {
             *   msg = AGTutorMessage.SolvedProblem;
             *   return true;
             * }
             */
            msg = AGTutorMessage.VerifyCorrect;
            return(true);
        }
Пример #2
0
        private void DeepVerify(IKnowledge source, IKnowledge obj, out string msg, out object output)
        {
            msg = AGTutorMessage.VerifyWrong;

            object result;
            var    shapeExpr = obj as AGShapeExpr;

            if (shapeExpr != null)
            {
                result = Reasoner.Instance.RelationValidate(shapeExpr.ShapeSymbol, out output);
            }
            else
            {
                result = Reasoner.Instance.RelationValidate(obj.Expr, out output);
            }

            if (result == null)
            {
                return;
            }

            var inputApproximateMatched = result as bool?;

            if (inputApproximateMatched != null)
            {
                if (inputApproximateMatched.Value)
                {
                    msg = AGTutorMessage.VerifyCorrect;
                }
                return;
            }

            var trace = result as List <Tuple <object, object> >;

            if (trace != null)
            {
                bool matchResult = UserGraph.Match(trace); //match and update
                if (matchResult)
                {
                    //insert nodes
                    UserGraph.Insert(trace);
                    CurrentStateNode = UserGraph.SearchInnerLoopNode(source); //update _currentStateNode;
                    //Debug.Assert(_currentStateNode != null);
                    msg = AGTutorMessage.VerifyCorrect;
                }
            }
        }
Пример #3
0
        private bool ShapeVerify(IKnowledge obj, ShapeSymbol shape, out string msg, out object output)
        {
            msg    = AGTutorMessage.VerifyWrong;
            output = null;

            List <Tuple <object, object> > trace = null;

            var agShapeExpr = new AGShapeExpr(obj.Expr, shape);

            agShapeExpr.IsSelected = true;
            agShapeExpr.GenerateSolvingTrace();
            trace = agShapeExpr.AutoTrace;

            if (trace == null || trace.Count == 0)
            {
                return(false);
            }

            /*   var lastTuple = trace[trace.Count - 1] as Tuple<object, object>;
             * var lastLst = lastTuple.Item2 as List<object>;
             * Debug.Assert(lastLst != null);
             * Debug.Assert(lastLst.Count != 0);
             * var lastTs = lastLst[lastLst.Count - 1] as TraceStepExpr;*/
            bool matchResult = UserGraph.Match(trace); //match and update

            if (!matchResult)
            {
                return(false);
            }

            //insert nodes
            UserGraph.Insert(trace);
            CurrentStateNode = UserGraph.SearchInnerLoopNode(obj); //update _currentStateNode;
            //var nextTuple1 = UserGraph.SearchNextInnerLoopNode(CurrentStateNode);

            /*  if (nextTuple1 == null) // query-end
             * {
             *    msg = AGTutorMessage.SolvedProblem;
             *    return true;
             * }*/
            msg = AGTutorMessage.VerifyCorrect;
            return(true);
        }