Ejemplo n.º 1
0
        public List <string> missingInMt(string goalMt, string nowMt)
        {
            List <Dictionary <string, string> > bingingsList = new List <Dictionary <string, string> >();
            // Find Desired List
            string        reqQuery = "precond(NEED)";
            List <string> needList = new List <string>();

            prologEngine.askQuery(reqQuery, goalMt, out bingingsList);
            foreach (Dictionary <string, string> bindings in bingingsList)
            {
                foreach (string k in bindings.Keys)
                {
                    if (k == "NEED")
                    {
                        if (!needList.Contains(bindings[k]))
                        {
                            needList.Add(bindings[k]);
                        }
                    }
                }
            }
            if (needList.Count == 0)
            {
                return(new List <string>());
            }
            // Find out what is missing
            List <string> missingList = new List <string>();

            foreach (string need in needList)
            {
                if (isPrologish(need))
                {
                    string needQuery     = need.Replace('"', ' ');;
                    bool   needSatisfied = prologEngine.isTrueIn(needQuery, nowMt);
                    if (!needSatisfied)
                    {
                        if (!missingList.Contains(need))
                        {
                            missingList.Add(need);
                        }
                    }
                }
                else
                {
                    string needQuery     = String.Format("state({0})", need);
                    bool   needSatisfied = prologEngine.isTrueIn(needQuery, nowMt);
                    if (!needSatisfied)
                    {
                        if (!missingList.Contains(need))
                        {
                            missingList.Add(need);
                        }
                    }
                }
            }
            return(missingList);
        }