Beispiel #1
0
        private string UpdateVerifiedMessage()
        {
            var status = UserGraph.CheckSolvingStatus();

            if (status == BehaviorGraph.SolvingStatus.Partial &&
                UserGraph.CurrentSolvingStatus == BehaviorGraph.SolvingStatus.None)
            {
                UserGraph.CurrentSolvingStatus = status;
                return(AGTutorMessage.SolvingPartialProblem);
            }

            if (status == BehaviorGraph.SolvingStatus.Complete &&
                UserGraph.CurrentSolvingStatus == BehaviorGraph.SolvingStatus.Partial)
            {
                UserGraph.CurrentSolvingStatus = status;
                return(AGTutorMessage.SolvedProblem);
            }

            if (status == BehaviorGraph.SolvingStatus.Complete &&
                UserGraph.CurrentSolvingStatus == BehaviorGraph.SolvingStatus.None)
            {
                UserGraph.CurrentSolvingStatus = status;
                return(AGTutorMessage.SolvedProblem);
            }

            return(null);
        }
Beispiel #2
0
        private QueryFeedbackState QueryBehaviorGraph(object obj, out string msg, out object output)
        {
            msg    = null;
            output = null;
            if (UserGraph == null)
            {
                return(QueryFeedbackState.QueryFailed);
            }
            if (UserGraph.Nodes.Count == 0 || UserGraph.Nodes.Count == 1)
            {
                msg = "TODO";
                return(QueryFeedbackState.QueryFailed);
            }

/*            if (!_queryProcessed)
 *          {
 *              _queryProcessed = true;
 *              output = UserGraph.SearchAllOuterEdgeInfos();
 *              msg = AGTutorMessage.InputQuery;
 *              return QueryFeedbackState.TutorQueryStarted;
 *          }*/

            if (obj != null)
            {
                return(VerifyBehaviorGraph(obj, out msg, out output));
            }
            Debug.Assert(obj == null);
            Debug.Assert(_currentStateNode != null);

            object            edgeInfo = null;
            BehaviorGraphNode nextNode = null;
            var nextTuple1             = UserGraph.SearchNextInnerLoopNode(_currentStateNode);

            if (nextTuple1 == null) // query-end
            {
                //partial checking
                BehaviorGraph.SolvingStatus ss = UserGraph.CheckSolvingStatus();
                if (ss == BehaviorGraph.SolvingStatus.Complete)
                {
                    msg = AGDemonstrationMessage.QueryEnd;
                    return(QueryFeedbackState.TutorQueryEnded);
                }
                else if (ss == BehaviorGraph.SolvingStatus.Partial)
                {
                    int nextGoalIndex = UserGraph.FindGoalIndex();
                    _currentStateNode = UserGraph.RetrieveInitInnerNode(nextGoalIndex);
                    nextTuple1        = UserGraph.SearchNextInnerLoopNode(_currentStateNode);
                    if (nextTuple1 == null)
                    {
                        msg = AGDemonstrationMessage.QueryEnd;
                        return(QueryFeedbackState.TutorQueryEnded);
                    }
                    CurrentStepHintRequired = true;
                }
                else
                {
                    msg = AGDemonstrationMessage.QueryEnd;
                    return(QueryFeedbackState.TutorQueryEnded);
                }
            }

            #region Path Selection

            var tuple11    = nextTuple1 as Tuple <object, object>;
            var tuple11Lst = nextTuple1 as List <Tuple <object, object> >;

            if (tuple11 != null)
            {
                edgeInfo = tuple11.Item1;
                nextNode = tuple11.Item2 as BehaviorGraphNode;
                //_currentStateNode = nextNode;
            }
            if (tuple11Lst != null)
            {
                var tupleTemp = tuple11Lst[0];
                edgeInfo = tupleTemp.Item1;
                nextNode = tupleTemp.Item2 as BehaviorGraphNode;
                //_currentStateNode = nextNode;
            }

            #endregion

            if (_currentStepHintRequired)
            {
                if (edgeInfo != null)
                {
                    var innerEdgeProp = edgeInfo as InnerLoopEdgeProperty;
                    Debug.Assert(innerEdgeProp != null);
                    msg = AGTutorMessage.QueryIntermediate;
                    _currentStepHintRequired = false;
                    //int parentIndex = UserGraph.SearchOuterLoopNodeIndex(_currentStateNode);
                    int parentIndex = UserGraph.SearchOuterLoopNodeIndex(nextNode);
                    var lst1        = UserGraph.SearchAllOuterEdgeInfos();
                    var tuple       = new Tuple <object, object, object>(innerEdgeProp.MetaRule, lst1, parentIndex);
                    output = tuple;
                }
                return(QueryFeedbackState.TutorQueryProcessedHint);
            }
            Debug.Assert(nextNode != null);
            _currentStepHintRequired = true;
            var nodeState = nextNode.State as InnerLoopBehaviorState;
            Debug.Assert(nodeState != null);
            var expr           = IKnowledgeGenerator.Generate(nodeState.UserKnowledge);
            var innerEdgeProp1 = edgeInfo as InnerLoopEdgeProperty;
            Debug.Assert(innerEdgeProp1 != null);
            var appliedRule = innerEdgeProp1.AppliedRule;
            //int parentIndex1 = UserGraph.SearchOuterLoopNodeIndex(_currentStateNode);
            int parentIndex1 = UserGraph.SearchOuterLoopNodeIndex(nextNode);
            var lst2         = UserGraph.SearchAllOuterEdgeInfos();
            output           = new Tuple <object, object, object, object>(appliedRule, expr, lst2, parentIndex1);
            CurrentStateNode = nextNode;
            return(QueryFeedbackState.TutorQueryProcessedAnswer);
        }